Python Forum
Remove extra count columns created by pandas groupby
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove extra count columns created by pandas groupby
#1
Is there anyway to remove the extra count columns created by pandas groupby?

I'm doing a groupby nunique on multiple columns so it does the grouping and also creates duplicate columns with counts (numbers)...
I don't want these columns as I am exporting to CSV . Can anyone suggest a solution?
Reply
#2
(Feb-02-2021, 11:25 PM)spyf8 Wrote: Is there anyway to remove the extra count columns created by pandas groupby?

I'm doing a groupby nunique on multiple columns so it does the grouping and also creates duplicate columns with counts (numbers)...
I don't want these columns as I am exporting to CSV . Can anyone suggest a solution?

Hello,
Yes, you can remove the extra column created by pandas groupby.
In order to assist you properly, it would be better if you could
share some working code that we can experiment with
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SORTED.group by and count average of two columns [ sum of col 1 / sum of col 2 ] BSDevo 1 638 Oct-23-2023, 09:47 PM
Last Post: BSDevo
  iretate over columns in df and calculate euclidean distance with one column in pandas Pit292 0 3,270 May-09-2021, 06:46 PM
Last Post: Pit292
  pandas.to_datetime: Combine data from 2 columns ju21878436312 1 2,421 Feb-20-2021, 08:25 PM
Last Post: perfringo
  Combine groupby() and shift() in pandas rama27 0 4,153 Nov-17-2020, 09:49 PM
Last Post: rama27
  Pandas: summing columns conditional on the column labels ddd2332 0 2,078 Sep-10-2020, 05:58 PM
Last Post: ddd2332
  Difference of two columns in Pandas dataframe zinho 2 3,318 Jun-17-2020, 03:36 PM
Last Post: zinho
  Pandas + Groupby + Filter unique values JosepMaria 1 2,844 Jun-15-2020, 08:15 AM
Last Post: JosepMaria
  python pandas: diff between 2 dates in a groupby bluedragon 0 3,254 Mar-25-2020, 04:18 PM
Last Post: bluedragon
  itertuples, datetime, pandas, groupby, in range karlito 0 2,426 Nov-29-2019, 11:35 AM
Last Post: karlito
  Pandas dataframe columns collapsed in Spyder when printing UniKlixX 2 4,661 Nov-04-2019, 07:00 AM
Last Post: UniKlixX

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020