Q. Write a program to create three different Series objects from the three columns of a DataFrame df.
You can understand by Watching video :-
Answer =
import pandas as pd d = {"col1":[1,4,3],"\ col2":[6,7,8],'\ col3':[9,0,1]} df = pd.DataFrame(d) s = pd.Series(data=df[df.columns[0]]) s1 = pd.Series(data=df[df.columns[1]]) s2 = pd.Series(data=df[df.columns[2]]) print(s) print() print(s1) print() print(s2)
Output :-
0 1
1 4
2 3
Name: col1, dtype: int64
0 6
1 7
2 8
Name: col2, dtype: int64
0 9
1 0
2 1
Name: col3, dtype: int64
>>>
hi
ReplyDeletehi
DeleteHi : )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )