Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Rank in pandas

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use Rank in pandas, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Rank

Rank is a ranking function that ranks the values of the original sequence according to the rules (from big to small, from small to big), and returns the ranking after the ranking.

For example, there is a sequence [1Magne7d5], which uses rank to rank from small to big, and returns [1mem4d3], which is the ranking position of each value in the previous sequence.

Usage:

Rank (axis=0, method: str = 'average', numeric_only: Union [bool, NoneType] = None, na_option: str =' keep', ascending: bool = True, pct: bool = False)

Parameter function:

(1) axis: row or column

(2) method: how to return the ranking. You can choose {'average',' min', 'max',' first', 'dense'}.

Method=average default setting: the same value occupies the top two, and you can't tell who is 1 and who is 2, then the median value is 1.5, and the following one is the third.

Method=max: two people tied for second place, and the next person is third.

Method=min: two people tied for 1st place, and the next person is 3rd.

Method=dense: two people tied for first place, and the next person is second place.

Method=first: the same value is set according to its relative position in the sequence

(3) ascending: positive order and reverse order

Rank the value_1 listed in df:

Df ['rank_1'] = df [' value_1'] .rank () df

The above is all the contents of the article "how to use Rank in pandas". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report