• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to keep column but not include in groupby

Resolved: How to keep column but not include in groupby

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a dataframe:
I want to do groupby by columns id type1 and max() by val. but when I do that:
I get:
But I want:
How to do that?

Answer:

You could use the idxmax function to find the index where the maximum val occurs and then map the value of type2 –
Output

If you have better answer, please add a comment about this, thank you!

dataframe group-by python python-3.x
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How do I stop the command from happening if the requirements for it to work aren’t sert Discord.js

02/04/2023

Resolved: How to scroll bottom of div at launch?

02/04/2023

Resolved: how to get and read an xml file in a zip file using xml.etree

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.