Category "pandas"

how to create dependent dropdownlist in python and streamlit?

based on the answer of this post i was able to display the dataframe after apply the required filter. I have a streamlit code that display multiple dropdown l

Getting SettingWithCopyWarning with iloc or loc when some filtering is done on the dataframe wit regex [duplicate]

I have the following statement to compute the mean of three quiz scores and create a new column based on the computed mean: scores.loc[:, 'Ave

How to json_normalize nested json arrays

I have the complex json structure as below. I am able to json_normalize only first level of array (MatchingReleases.MatchingRelease). whereas I have one more

How can I substring to specific character in pandas?

For example, I have 2 columns(1,2), and in table 2 I want to fetch everything until " character. I wanted to do something like this: df.columns = ['1','2'] a =

fastapi using ORM not able to convert to pandas

I've been developing a fastapi way to query my database, instead of directly using SQL with pg. For some reason, I'm having issues converting the ORM query retu

`pd.read_sql(sql, engine)` raises NotImplementedError: This method is not implemented for SQLAlchemy 2.0

I tried to create a pandas DataFrame directly from my sqlserver database using an sqlalchemy engine: engine = create_engine(URL_string, echo=False, future=True)

pandas | list in column to binary column

I have the following dataframe: +------------+------------------+ | item | categories | +------------+------------------+ | blue_shirt | ['red', 'wh

How to find current upper Bollinger band in pandas-ta

I have a CSV file having columns Instrument, Date, Time, Open, High, Low, Close I want the rows having Current close greater than current upper Bollinger band(2

custom method for voting bewtween multiple csv files

I have 3 (or more) Dataframes with this structure: ID Percentage 00001 3 00002 15 00003 73 00004 90 ... ... each csv have unique predicted percentage values a

Pandas Dataframe Categorical data transformation

I am having pandas dataframe as follows: import pandas as pd # dictionary with list object in values # Item=[Item1, Item2, Item3] details = { 'Date' : [

Use Index of the Loadings (IL) method to calculate the optimal number of principal components

I want to use Index of the Loadings method to calculate the optimal number of principal components using the index_of_loadings_matrix function. My dataframe was

Exploding multiple dict columns and concatenating with original Pandas data frame

I export a Postgres SQL query to create a Pandas data frame df similar to the following: df = pd.DataFrame({ 'employee_id' : [123, 456, 789], 'country_c

Change values of column in df using conditional in two columns

I'm having the following problem: I'm working with a dataset that can be found at https://www.kaggle.com/datasets/ricardomattos05/jogos-do-campeonato-brasileiro

Efficiency of multiple chained str transformation and alternatives

I'm wanting to change a dataframe column so the values are lower case and also have their whitespace stripped. For this I used chained str transformations. df.l

Change NaN to None in Pandas dataframe

I try to replace Nan to None in pandas dataframe. It was working to use df.where(df.notnull(),None). Here is the thread for this method. Use None instead of np.

Change NaN to None in Pandas dataframe

I try to replace Nan to None in pandas dataframe. It was working to use df.where(df.notnull(),None). Here is the thread for this method. Use None instead of np.

Python Pandas - Lookup a variable column depending on another column's value

I'm trying to use the value of one cell to find the value of a cell in another column. The first cell value ('source') dictates which column to lookup. import p

Predicting with SMOTE

If I have a training dataset that has 1083 samples and a testing dataset that has 79871 samples, how do I go about making the samples equal? I have been using S

pandas read_csv throwing ValueError: Invalid file path or buffer object type: <class 'list'>

I want to read a csv file sent as a command line argument. Thought I could directly use FileType object of argsprase but I'm getting errors. from argparse impor

Repeat rows in a pandas DataFrame based on column value

I have the following df: code . role . persons 123 . Janitor . 3 123 . Analyst . 2 321 . Vallet . 2 321 . Auditor . 5 The first line means that I hav