I got csv dataset like this and i need to remove any empty rows inside of it i already tried following code but still it fails when it reads empty row, and return pandas.errors.ParserError: Error tokenizing data. C error: Expected 7 fields in line 11, saw 8 sample dataset how can i remove those empty rows usi…
Tag: pandas
Get pandas boxplot in one plot and matplotlib plot in another figure
When I run the program, the two plots are plotted in one figure, but I want them in two separate figures. Answer The pandas.DataFrame.boxplot takes an ax parameter, as written in the docs. So you can use: Otherwise, you can plot in different subplots of the same figure by applying minimal changes.
How to create a list from dataframe pandas
My dataset contains columns of usersID and itemsID that they have purchased. Each user might have purchased more than 1 item. I neeed to make a list so that the key will be the userID and the values the itemsID he purchased for example if user_1 has purchased [item_20,item_25,item_32], my dataset contains 3 r…
How can I avoid for-loops using pandas?
Would love to know how to optimize this code without using for-loops, if it’s possible. What I’m trying to do is to categorize all the values in series df[‘Состояние’] looking at key words in lists list_rep and list_dem one by one. Thank you! Answer Use Series.str.lower fiirst, then Se…
ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed
I was trying to print a plotly plot in Visual Studio Code and caught this error: The code I used: I tried pip install nbformat in the console following this feed on GitHub and this question on stackoverflow but it did not work. However, it seems the code could run with the last 2 rows removed: Answer Method 1…
Need help converting column timestamp data into 2 seperate columns (Date,Time)
Fairly new to programming and python in general. Learning as I go. Breaking thing, ALOT, but learning ALOT. What I want to do, which I have not been able to figure out is create a CSV with certain columns. Currently, one of the columns, after I organize the data, is a date-timestamp, which I need to be separa…
create multiple excel files with the data in dataframe using python
I have a sample dataframe1 How do I iterate through the manager column in such a way that rows/data of one manager should be saved in excel and the rows/data of another manager should be saved in another excel? desired result first excel data (filename: ABC – XYZ, MNO) second excel data (filename: XYZ &…
Delete duplicates if multiple fields follow conditions?
I had a simple Excel task to do today that I figured i’d use some Python to clean up. This led me to pandas and numpy.This is what i’d like to know if possible: I have these columns and about 5k rows: First Name | Last Name | Email | Address | City I want to remove duplicates that fall
Pandas subtract each column in dataframe_a from all columns of dataframe_b and write result to third dataframe
I have dataframe_a and dataframe_b filled with an variable number of columns but the same number of rows. I need to subtract each column of dfb from all dfa columns and create a new dataframe containing the subtracted values. Right now I’m doing this manually: then I’m using the concat function to…
Splitting single-columned .CSV into multiple columns with Pandas
I’m interested to know how to elegantly go about splitting a single-columned file of the following format into a more classic tabular layout using Pandas. (The file is received as an output from an eye tracker.) Current Format: Desired Format: Where I’m stuck: I imagine the solution will involve P…