- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does axes in the pandas series mean?
The “axes” is an attribute of the pandas series object, this attribute is used to access the group of index labels in the given Series. It will return a python list of index labels.
The axes attribute collects all the index labels and returns a list object with all index labels in it.
Example 1
import pandas as pd # create a sample series s = pd.Series({'A':123,'B':458,"C":556, "D": 238}) print(s) print("Output: ") print(s.axes)
Explanation
In the following example, we initialized a Series with some data. Then we called the axes property on the series object.
Output
A 123 B 458 C 556 D 238 dtype: int64 Output: [Index(['A', 'B', 'C', 'D'], dtype='object')]
The output of the initial series object, and the output of the axes attribute, can be seen in the above output block.
The output for the axes attribute is a list which is holding the index labels A, B, C, D of the series.
Example 2
import pandas as pd # create a sample series s = pd.Series([37,78,3,23,5,445]) print(s) print("Output: ") print(s.axes)
Explanation
In this example, we have initialized a series object without specifying the index, So here the default index will be created for the series object. And the values are assigned through a python list with integer elements.
Output
0 37 1 78 2 3 3 23 4 5 5 445 dtype: int64 Output: [RangeIndex(start=0, stop=6, step=1)]
We got the python list object as an output for the axes property and the data present in the list is range values which represent the index label of the series.
- Related Articles
- What does series mean in pandas?
- What does count method do in the pandas series?
- What does the all() method do in pandas series?
- Print the mean of a Pandas series
- What does the add() method do in the pandas series?
- What does the align() method do in the pandas series?
- What does the any() method do in the pandas series?
- What does the apply() method do in the pandas series?
- What does agg() method do in pandas series?
- What do axes attribute in the pandas DataFrame?
- How does pandas series argsort work?
- How does the pandas Series idxmax() method work?
- How does the pandas Series idxmin() method work?
- How does pandas series astype() method work?
- How does pandas series combine() method work?
