4. Write a Numpy program first to show the numpy array in the following a1, then convert the numpy array to pandas series.
The output is:
a1 = ['Python', 'Pandas', 'Free', 'Exercises', 'Solutions']
Expected Answer:
NumPy array:
['Python' 'Pandas' 'Free' 'Exercises' 'Solutions']
Converted to Pandas series:
0 Python
1 Pandas
2 Free
3 Exercises
4 Solutions
dtype: object
Sample Answer:
import numpy as np import pandas as pd np_array = np.array(['Python', 'Pandas', 'Free', 'Exercises', 'Solutions']) print("NumPy array:") print(np_array) pandas_series = pd.Series(np_array) print("\nConverted to Pandas series:") print(pandas_series)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)