Assuming you have a pandas DataFrame called df
with columns "begin_time" and "nl10107" (among others):
main.py235 chars6 lines
Explanation:
sort_values()
method of a pandas DataFrame to sort the rows by the values in the "nl10107" column.groupby()
method to group the rows by "begin_time", and the sum()
method to sum up the values in the "nl10107" column for each group.nlargest()
method with a parameter of 5
to get the 5 largest values in the resulting Series, and extract their index (i.e. the "begin_time" values) using the index.tolist()
method.Note: Make sure the concentration of "o3" is indeed stored in the "nl10107" column of the DataFrame.
gistlibby LogSnag