I am creating a small financial management program which imports my transactions from CSV into Python. I want to assign values to a new column ‘category’ based on strings found in the ‘details’ column. I can do it for one, but my question is how do I do it if I had a huge list […]
Tag: pandas
Imbalanced-Learn’s FunctionSampler throws ValueError
I want to use the class FunctionSampler from imblearn to create my own custom class for resampling my dataset. I have a one-dimensional feature Series containing paths for each subject and a label Series containing the labels for each subject. Both come from a pd.DataFrame. I know that I have to reshape the feature array […]
How to create a Pandas DataFrame from dictionary of dataframes?
I have a dictionary that is a list of dataframes that have all the same columns and data structure. I am wanting to essentially ‘union’ all of these into a single dataframe again, where the …
Pandas: How to read CSV file from google drive public?
I searched similar questions about reading csv from URL but I could not find a way to read csv file from google drive csv file. My attempt: import pandas as pd url = ‘https://drive.google.com/file/…
Specify ordering for columns when creating a DataFrame from list of dictionaries
I have a method that creates a list, results, and then appends to it a dict row which has keys (column names in my eventual dataframe) and values (row values in my eventual dataframe). Then I append the row and convert the results collection to a df at the end. For example: The issue I […]
resample/interpolate time series with datetimeindex
I have two dataframes each containing one or more time series from the same time frame but sampled at different timestamps. I’d like to merge them into a single one resampled and interpolated with the index of the first. Here’s a sample of the first dataframe: And the second one: In this case the second […]
How to get a user input for a column in pandas by creating a GUI using tkinter?
I have a dataframe with 3 columns: Date, attribute_one, attribute_two. The date column is blank but the other two columns are filled with some data. how can I use tkinter package to build a GUI which would prompt the user to enter date which will then be eventually stored in the dataframe. AdvertisementAnswer Using the […]
Creating pandas series from array and list
I’m trying to map array data to a list of column names but keep getting this error message This is a sample of the data in a and the list of rows in cols: The endgoal is to create a series showing the coefficients of each feature (represented by the cols list) AdvertisementAnswer You array […]
Mute DEBUG alerts from ‘import pandas’ statement
I’m importing pandas and it continues to throw 7 DEBUG messages. It’s happening in JupyterLab and pythonanywhere. It does not appear when I comment out the pandas import I tried to mute them using: warnings.filterwarnings(“ignore”), to no avail. Tried “from pandas import pandas as pd” to try and avoid any further import, etc. … goes […]
How to create a pandas dataframe where columns are filled with random strings?
I want to create a Pandas dataframe with 2 columns and x number rows that contain random strings. I have found code to generate a pandas dataframe with random ints and a random stringer generator. I still don’t see a clear path to create a pandas data frame with random strings. Code for random int […]