Converting groupby dataframe (with dropped duplicate rows by group) into normal dataframe

user3314418

How do I convert a groupby dataframe I created in order to drop duplicates by a group back into a normal dataframe?

df3 = df2.groupby('Organization')
df3 = df3.drop_duplicates('Name')

I tried this, but this seems to create abnormal properties that don't allow me to subset my data

df3 = df3.add_suffix(' ').reset_index()
df3 = df3.set_index(df3.level_1)
df3.columns = map(lambda x: x.strip(), df3.columns)
df3.ix[:,2:]

AssertionError: Number of manager items must equal union of block items
# manager items: 12, # tot_items: 13
zerovector

Instead of creating a groupby to drop duplicates, have you considered:

df4 = df3.drop_duplicates(['Organization', 'Name'])

That will keep you in a normal dataframe the whole time and should accomplish what you're trying to do.

If you want to group and "ungroup" then this post may help

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to group dataframe rows into list in pandas groupby

From Dev

converting columns to rows in a Pandas DataFrame

From Dev

pandas DataFrame sort rows by duplicate

From Dev

Consolidating duplicate rows in a large dataframe

From Java

Converting a Pandas GroupBy output from Series to DataFrame

From Dev

Converting Groupby Object into DataFrame objects in a loop

From Dev

insert dataframe into rows for each group in another dataframe

From Dev

duplicate rows of dataframe by factor level index

From Dev

removing duplicate rows in pandas DataFrame based on a condition

From Java

Remove rows with duplicate indices (Pandas DataFrame and TimeSeries)

From Dev

Spark remove duplicate rows from DataFrame

From Dev

Add duplicate dataframe rows in a call to apply()

From Dev

Removing Duplicate rows and Calculate the Average in a Dataframe in R

From Dev

R: how to join the duplicate rows in one dataframe

From Dev

How to count duplicate rows in pandas dataframe?

From Dev

Pandas dataframe perform calculations on duplicate rows

From Dev

How to efficiently remove duplicate rows from a DataFrame

From Dev

add duplicate rows to R dataframe based on sequence

From Dev

Groupby a column from another (same # of rows) dataframe

From Dev

Drop pandas dataframe rows based on groupby() condition

From Dev

saving dataframe groupby rows to exactly two lines

From Dev

Groupby a column from another (same # of rows) dataframe

From Dev

using groupby on pandas dataframe to group by financial year

From Dev

Pandas Dataframe GroupBy - Displaying Group Statistics

From Dev

GroupBy operation using an entire dataframe to group values

From Dev

using groupby on pandas dataframe to group by financial year

From Dev

How to convert a triplet DataFrame to a new DataFrame with no duplicate rows?

From Dev

Filter the duplicate rows of a pandas dataframe, keeping rows with the latest date only

From Dev

Sample n random rows per group in a dataframe

Related Related

  1. 1

    How to group dataframe rows into list in pandas groupby

  2. 2

    converting columns to rows in a Pandas DataFrame

  3. 3

    pandas DataFrame sort rows by duplicate

  4. 4

    Consolidating duplicate rows in a large dataframe

  5. 5

    Converting a Pandas GroupBy output from Series to DataFrame

  6. 6

    Converting Groupby Object into DataFrame objects in a loop

  7. 7

    insert dataframe into rows for each group in another dataframe

  8. 8

    duplicate rows of dataframe by factor level index

  9. 9

    removing duplicate rows in pandas DataFrame based on a condition

  10. 10

    Remove rows with duplicate indices (Pandas DataFrame and TimeSeries)

  11. 11

    Spark remove duplicate rows from DataFrame

  12. 12

    Add duplicate dataframe rows in a call to apply()

  13. 13

    Removing Duplicate rows and Calculate the Average in a Dataframe in R

  14. 14

    R: how to join the duplicate rows in one dataframe

  15. 15

    How to count duplicate rows in pandas dataframe?

  16. 16

    Pandas dataframe perform calculations on duplicate rows

  17. 17

    How to efficiently remove duplicate rows from a DataFrame

  18. 18

    add duplicate rows to R dataframe based on sequence

  19. 19

    Groupby a column from another (same # of rows) dataframe

  20. 20

    Drop pandas dataframe rows based on groupby() condition

  21. 21

    saving dataframe groupby rows to exactly two lines

  22. 22

    Groupby a column from another (same # of rows) dataframe

  23. 23

    using groupby on pandas dataframe to group by financial year

  24. 24

    Pandas Dataframe GroupBy - Displaying Group Statistics

  25. 25

    GroupBy operation using an entire dataframe to group values

  26. 26

    using groupby on pandas dataframe to group by financial year

  27. 27

    How to convert a triplet DataFrame to a new DataFrame with no duplicate rows?

  28. 28

    Filter the duplicate rows of a pandas dataframe, keeping rows with the latest date only

  29. 29

    Sample n random rows per group in a dataframe

HotTag

Archive