CBSE Class 12 Informatics Practices
Question 115 of 167
Python Pandas — I — Question 5
Back to all questions 5
Question Write a Python program to create a series object, country using a list that stores the capital of each country.
Note. Assume four countries to be used as index of the series object are India, UK, Denmark and Thailand having their capitals as New Delhi, London, Copenhagen and Bangkok respectively.
import pandas as pd
capitals = ['New Delhi', 'London', 'Copenhagen', 'Bangkok']
countries = ['India', 'UK', 'Denmark', 'Thailand']
country = pd.Series(capitals, index=countries)
print(country)India New Delhi
UK London
Denmark Copenhagen
Thailand Bangkok
dtype: object