In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Python in how to use pandas to achieve sorting, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Pandas sorting
Sorting in pandas is also very simple, and basically consistent with the process principles on Excel, after all, are data tools. As follows:
-DataFrame.sort_values (), you can sort it.
-the first parameter specifies that the sort is based on the key column
-the second parameter specifies the ascending and descending order of the key column corresponding to the first parameter
-you can also set axis=1 to sort by row (less practical application scenarios)
Sorting in Excel can customize the sequence, that is, let the user customize the order, in pandas, this function is not implemented in sort_values.
> in fact, custom sequences are also placed in separate functions in Excel
For example, you want the class to be sorted according to "5, 4, 2, 1, 3, 6, 7", as follows:
-in pandas, you need to construct a column Categorical as an auxiliary column.
The second parameter specifies the order when the Categorical is instantiated
-finally, the custom sorting can be completed by also calling the sort_values method.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.