Advertisements
Advertisements
Question
Write a Python program to create a Pandas Series as shown below from an ndarray containing the numbers 10, 20, 30, 40, 50 with corresponding indices ‘A’, ‘B’, ‘C’, ‘D’, ‘E’.
| A | 10 |
| B | 20 |
| C | 30 |
| D | 40 |
| E | 50 |
Code Writing
Advertisements
Solution
import pandas as pd
import numpy as np
data = np.array([10, 20, 30, 40, 50])
indices = ['A', 'B', 'C', 'D', 'E']
series = pd.Series(data, index=indices)
print(series)shaalaa.com
Is there an error in this question or solution?
