2. Write a Python Pandas program first to show a one dimensional array-like object contains the array in the following output. Therefore convert the type of pandas series to python list.
The output is:
a = ['Python', 'Pandas', 'Free', 'Exercises', 'Solutions']
Expected Answer:
Initial Pandas Series:
0 Python
1 Pandas
2 Free
3 Exercises
4 Solutions
dtype: object
Initial Pandas Type: [class 'pandas.core.series.Series']
Convert from Pandas Series to Python list
['Python', 'Pandas', 'Free', 'Exercises', 'Solutions']
Python Type: [class 'list']
Sample Answer:
import pandas as pd a = pd.Series(['Python', 'Pandas', 'Free', 'Exercises', 'Solutions']) print("Initial Pandas Series:") print(a) print("\nInitial Pandas Type:", type(a)) print("\nConvert from Pandas Series to Python list") print(a.tolist()) print("\nPython Type:", type(a.tolist()))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)