In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the Pandas library DataFrame how to sort, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Df1 is the test data of dataframe structure:
The df1 data is read from the test.xlsx document, and the sample code is as follows:
#-*-coding:utf-8-*-import tushare as tsimport pandas as pddf = pd.read_excel ('test.xlsx') df1 = df.head (10) # dataframe is sorted in ascending order. The default is ascending order # print df1.sort_index () # dataframe sorting in descending order # print df1.sort_index (ascending=False) # the first line is sorted in ascending order The default is ascending print df1.sort_index (axis=1) # the first line is sorted by descending order # print df1.sort_index (axis=1, ascending=False) # sort by the value of the column amount, by default from small to large # print df1.sort_values (by='amount') # sort by the value of the column amount, from large to small # print df1.sort_values (by='amount', ascending=False) # sort by multiple columns, and by the values of the amount and price columns From big to small # print df1.sort_values (by= ['amount',' price'], ascending=False) thank you for reading this article carefully. I hope the article "how to sort the DataFrame of Pandas Library" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.