Skip to content
Advertisement

Category: Questions

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

How can I prepare my image dataset for a federated model?

How could I transform my dataset (composed of images) in a federated dataset? I am trying to create something similar to emnist but for my own dataset. tff.simulation.datasets.emnist.load_data( only_digits=True, cache_dir=None ) Answer You will need to create the clientData object first for example: where create_dataset is a serializable function but first you have to prepare your images read this tutorial

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

Advertisement