I have make a form with tKinter that has 2 Entries (username, password) I also have a csv file that contains my user info I am importing the file like so: I want to get the username and password that the user is going to give me and check if they are in my dataframe I figured out that I
Tag: pandas
Apply a function including if to each row of a dataframe in pandas without for loop
Given a dataframe, I want to get the nonzero values of each row and then find the minimum of absolute values. I want to have a user defined function that does this for me. Also, I do not want to use any for loop since the data is big. My try I get ValueError: The truth value of a Series
How to remove a group of specific rows from a dataframe?
I have a dataframe with 7581 rows and 3 columns (id,text,label). And I have a subgroup of this dataframe of 794 rows. What I need to do is to remove that subgroup of 794 rows (same labels) from the big dataframe of 7581. This is how the subgroup looks like: Photo I have tried to do this: But the following
How do i df.fillna with category median values
I have a large dataset ~1mln rows, and about 5000 absent coordinates(i’d like to fill them with median value by category ‘city’everything but fillna is working, how to make it happen? Answer You could do: First groupby with the city, then use transform with fillna and calculate the median. (you could use any mathematical operation)
Pandas dataframe – fillna with last of next month
I’ve been staring at this way too long and I think Ive lost my mind, it really shouldn’t be as complicated as I’m making it. I have a df: Date1 Date2 2022-04-01 2022-06-17 2022-04-15 2022-04-15 2022-03-03 NaT 2022-04-22 NaT 2022-05-06 2022-06-06 I want to fill the blanks in ‘Date2’ where it keeps the values from ‘Date2’ if they are present
Is it possibe to change similar libraries (Data Analysis) in Python within the same code?
I use the modin library for multiprocessing. While the library is great for faster processing, it fails at merge and I would like to revert to default pandas in between the code. I understand as per PEP 8: E402 conventions, import should be declared once and at the top of the code however my case would need otherwise. Then I
Faster alternative to groupby, unstack then fillna
I’m currently doing the following operations based on a dataframe (A) made of two columns with multiple thousands of unique values each. The operations performed on this dataframe are: The output is a table (B) with unique values of col1 in rows and unique values of col2 in columns, and each cell is the count of rows, from the original
Convert string duration column to seconds
In the dataframe, one of the columns is duration. It was given as a string. How can I convert this column into seconds? Answer Use pd.Timedelta to parse each item: Output:
Replace value based on a corresponding value but keep value if criteria not met
Given the following dataframe, INPUT df: Cost_centre Pool_costs 90272 A 92705 A 98754 A 91350 A Replace Pool_costs value with ‘B’ given the Cost_centre value but keep the Pool_costs value if the Cost_centre value does not appear in list. OUTPUT df: Cost_centre Pool_costs 90272 B 92705 A 98754 A 91350 B Current Code: This code works up until the else
Is it possible to do “rolling mean” first and then “groupby sum” in ONE GO?
For below given working codes , is it possible to compute rolling mean first and then do groupby sum in ONE GO ? I don’t want to create calculated columns in df2 as it is resulting in lots of additional columns for each value in “Mean-1 input Value” Suggestion given is working fine for one input value , want to