6. Write a Pandas program to show the pandas series with a1 and a2 content. Therefore compare the equality of two elements.
The output is:
a1 = ['Python', 'Pandas', 'Free', 'Exercises', 'Solutions']
a2 = ['Python', 'Numpy', 'Free', 'Answers', 'Solutions']
Expected Answer:
Pandas Series 1:
0 Python
1 Pandas
2 Free
3 Exercises
4 Solutions
dtype: object
Pandas Series 2:
0 Python
1 Numpy
2 Free
3 Answers
4 Solutions
dtype: object
Compare the equality of Pandas Series 1 and 2:
0 True
1 False
2 True
3 False
4 True
dtype: bool
Sample Answer:
import pandas as pd a1 = pd.Series(['Python', 'Pandas', 'Free', 'Exercises', 'Solutions']) a2 = pd.Series(['Python', 'Numpy', 'Free', 'Answers', 'Solutions']) print("Pandas Series 1:") print(a1) print("\nPandas Series 2:") print(a2) print("\nCompare the equality of Pandas Series 1 and 2:") print(a1 == a2)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)