KnowledgeBoat Logo
|

Informatics Practices

Write a program to create three different Series objects from the three columns of a DataFrame df.

Python Pandas

3 Likes

Answer

import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})
s1 = df['A']
s2 = df['B']
s3 = df['C']
print(s1)
print(s2)
print(s3)

Output

0    1
1    2
2    3
Name: A, dtype: int64
0    4
1    5
2    6
Name: B, dtype: int64
0    7
1    8
2    9
Name: C, dtype: int64

Answered By

1 Like


Related Questions