The index objects are responsible for labelling the axis. For example
Index
Objects
•
The index objects are responsible for labelling the axis. For example
import pandas as pd
data = [10,20,30,40]
x = pd.Series(data,
index=["a","b","c","d"], dtype = float)
print(x)
index = x.index← index
object
print(index)
a 10.0
b 20.0
c 30.0
d 40.0
dtype: float64
Index(['a', 'b', 'c', 'd'], dtype='object')
The
above output indicates that we can display the labels of indices using the
index object.
Now
if we want to change the label of some index then we get an error because the
index objects are immutable
In [7]: index[1] = "w"
Traceback (most recent call last):
Cell In[7], line 1
index[1]
= "w"
File ̰ \anaconda3\Lib\site‒packages\pandas\core\indexes\base.py:5157in_setitem_raise
TypeError("Index does not support mutable operations")
TypeError: Index does not support mutable operations.
Method : Purpose
append
‒ The function is used to append a single or a collection of indices together.
In the case of a collection of indices, all of them get appended to the original
index in the same order as they are passed to the Index.append() function.
difference
‒ This function computes the set differences as an index.
intersection
‒ This function computes the set intersection as an index.
union
‒ Computes the set union.
delete
‒ This function computes the new index with the element at index i is deleted.
insert
‒ This function computes the new index by inserting element at index i
is_ unique
‒ This function returns true if the index has no duplicate values.
unique
‒ Computes the array of unique values in the index.
Python for Data Science: Chapter 5: NumPy and Pandas Libraries : Tag: Computer Programming, Python, Data Science : Python library - Pandas: Index Objects
Python for Data Science
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation
English Essentials II
EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Tamils and Technology தமிழர்களும் தொழில்நுட்பமும்
UC25H02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Linear Algebra
MA25C02 2nd Semester | 2025 Regulation
Applied Physics (CSIE) II
PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Digital Principles and Computer Organization
CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electrical and Electronics Engineering
EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Python for Data Science
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Re-Engineering for Innovation
ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Python for Data Science - Laboratory
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation