0

I have the following condition:

df[‘hour’].value_counts()==df[‘hour’].value_counts().max()

i want to create a variable that holds the value of maximum occurrences. as example: if max occurrences is 55 at hour 19, then i need a variable that holds the value 19

k_a
  • 1
  • 2
  • 3
    `df["hour"].idxmax()` - https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.idxmax.html – Dishin H Goyani Aug 13 '20 at 13:27
  • As a start you will need another column that holds the time of the temperature measurement ... then you can make a histogram of frequency of temp occurrences. – Bruno Vermeulen Aug 13 '20 at 13:29
  • @BrunoVermeulen there's no temperature measurement and i don't need a histogram i can find the maximum occurrences using .max() – k_a Aug 13 '20 at 14:01
  • @DishinHGoyani i tried your code but i din't get the correct answer – k_a Aug 13 '20 at 14:04
  • @BrunoVermeulen there is a column for the time which is hour – k_a Aug 13 '20 at 15:08
  • @k_a I guess It is confusing what you want from your explanation. Best way to get right answer quickly is to provide some minimum reproducible example with your expected output and dummy inputs. [how-to-make-good-reproducible-pandas-examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – Dishin H Goyani Aug 14 '20 at 06:45
  • @DishinHGoyani i modified the code above. i need to store the value of time (hour) at which the maximum occurs. as example if the max. no. of occurrences is at hour 18 i need to store this value in a variable – k_a Aug 14 '20 at 17:36

0 Answers0