Pandas is a set of fast and efficient data analysis tools for Python. It can be used for data mining and data analysis, and also provides data cleaning capabilities. The table of contents of this article is as follows:
i. iloc
1. Definitions
The iloc indexer is used for integer position-based indexing or selection by position.
2. Grammar
[row selection, column selection]
3.Code Example
(1) Importing data
(2) Select Single Row or Single Column
(3) Select multiple rows or columns
(4) Attention
iloc select a line to return to the Series, select multiple lines to return to the DataFrame, by passing the list can be converted to DataFrame.
II. Loc
1. Definitions
Loc selects data by label or index, boolean value or condition, which is a more common method of selecting data.
2. Grammar
[row selection, column selection]
3.Code Example
(1) Use loc for tag-based or index-based methods
1) First set up the index
(2) According to the index to select a single row or column
3) Select multiple rows and columns according to the index
(2) Boolean/logical indexing using loc
(3) More examples of loc selection data
(4) Using loc to set values in DataFrame
technical exchange
Feel free to republish, bookmark, and like something to support it!
The above is Python Pandas data analysis of iloc and loc usage details, more information about Python data analysis please pay attention to my other related articles!