In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people have no idea about how to use the df.iloc [] method of pandas in python. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Unlike df.loc [], which acquires data based on row or column labels, df.iloc [] is obtained according to the coordinates (position) of the data, as identified by the red number in the following figure:
Iloc [] also accepts two parameters, which represent row coordinates and column coordinates. Acceptable parameters
Types are numbers, lists of numeric types, and slices
The following examples are given:
Name score grade
Id
A bog 45 A
C jiken 67 B
D bob 23 A
B jiken 34 B
F lucy 98 A
E tidy 75 B
# get data with coordinates (0,0)
> df.iloc [0,0]
'bog'
# get all the data in 0 rows. The column coordinate parameter is empty. The whole row is obtained by default.
> df.iloc [0]
Name bog
Score 45
Grade A
Name: a, dtype: object
# get the data of the specified row and column
> df.iloc [[0jue 1], [0Jet 1]]
Name score
Id
A bog 45
C jiken 67
# arrange all rows in reverse order
> df.iloc [::-1,::-1]
Grade score name
Id
E B 75 tidy
F A 98 lucy
B B 34 jiken
D A 23 bob
C B 67 jiken
An A 45 bog
After reading the above, have you mastered how to use the df.iloc [] method of pandas in python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.