The second count comes out well, but the descending order doesn't work. Sort() doesn't work
'dict' object has no attribute 'sort'
If you apply sort
, it appears like this.
Dictionaries don't have an order.
If you want to sort, you can change it to a list, but if you wrote a dictionary for the purpose of counting, what's better is the collections counter.
But then again, the ID to count seems to be a column in the data frame. It is best to write value_counts.
id_ounter = df["ID"].value_counts()
Sort and escalating factors can determine whether to sort or not and the direction of sorting.
https://pandas.pydata.org/docs/reference/api/pandas.Series.value_counts.html#
572 Understanding How to Configure Google API Key
596 GDB gets version error when attempting to debug with the Presense SDK (IDE)
884 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
603 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.