To create this DataFrame using a Dictionary of Series, we can define each column as a Series first and then combine them into a DataFrame.
Here is the correct Python code:
import pandas as pd
city_series = pd.Series(['Mumbai', 'Dehradun', 'Bengaluru',
'Hyderabad'])
state_series = pd.Series(['Maharashtra', 'Uttarakhand', 'Karnataka',
'Telangana'])
data = {'City': city_series, 'State': state_series}
df = pd.DataFrame(data)
print(df)
Explanation:
1. We first import pandas and alias it as pd.
2. We create two Series: one for the City column and one for the State column.
3. We store these Series in a dictionary where keys are column names.
4. We pass the dictionary to pd.DataFrame() to create the DataFrame.
5. Finally, we print the DataFrame to display the output in tabular form.
This produces the required DataFrame exactly as shown.