Explanation:
๐ 1. Importing the Library
import pandas as pd
pandas is a powerful Python library used for data analysis and manipulation.
as pd gives it a short alias (pd) so you don’t have to type pandas every time.
๐ 2. Creating a Series
clcoding = pd.Series([10, 20, 30], index=[1, 2, 3])
pd.Series() creates a one-dimensional labeled array.
[10, 20, 30] → These are the data values.
index=[1, 2, 3] → These are the custom labels (indexes) assigned to each value.
๐ So the Series looks like this internally:
1 10
2 20
3 30
๐ 3. Accessing Data Using iloc
print(clcoding.iloc[1])
iloc stands for integer-location based indexing.
It accesses data using position (starting from 0), NOT the index labels.
๐ Positions:
Position 0 → 10
Position 1 → 20
Position 2 → 30
So:
clcoding.iloc[1] → gets the second element → 20
๐ 4. Output
20

0 Comments:
Post a Comment