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
2 Likes
Related Questions
Three Series objects store the marks of 10 students in three terms. Roll numbers of students form the index of these Series objects. The Three Series objects have the same indexes.
Calculate the total weighted marks obtained by students as per following formula :
Final marks = 25% Term 1 + 25% Term 2 + 50% Term 3Store the Final marks of students in another Series object.
Write code to print all the information about a Series object.
Write a program to create three different Series objects from the three rows of a DataFrame df.
Write a program to create a Series object from an ndarray that stores characters from 'a' to 'g'.