• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Python pandas: shows rows based on unique values

Resolved: Python pandas: shows rows based on unique values

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

Question:

I’m a new Python learner, and I can’t figure out how to do this.
Let’s say I have a data frame like this:
I want to select rows only for each title with most hours_viewed, the result will look like this:
Thank you in advance.

Answer:

here is one way to do it
using groupby, we take the max across category & title and then comparing the result with the original df.

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

pandas python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Reshape tensors of unknown shape with tf.function

26/03/2023

Resolved: Use Svelte Component as Slot

26/03/2023

Resolved: Vaadin 14.9 – Redirect on Session Destroy Event

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

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