Write a Python script that creates a data frame from the given dictionary. data_dict =…
- User
Write a Python script that creates a data frame from the given dictionary. data_dict = {"Country":["India", "Germany", "USA", "Indonesia"], "Capital":["Delhi", "Berlin", "Washington DC", "Jakarta"], "Currency":["Rupee", "Euro", "US Dollar", "Rupiah"]}
Assistant
Here is the Python script to create a DataFrame using the
pandaslibrary.import pandas as pd # 1. Define the dictionary data_dict = { "Country": ["India", "Germany", "USA", "Indonesia"], "Capital": ["Delhi", "Berlin", "Washington DC", "Jakarta"], "Currency": ["Rupee", "Euro", "US Dollar", "Rupiah"] } # 2. Create the DataFrame df = pd.DataFrame(data_dict) # 3. Display the DataFrame print(df)Expected Output:
When you run this script, it will produce the following output:
Country Capital Currency 0 India Delhi Rupee 1 Germany Berlin Euro 2 USA Washington DC US Dollar 3 Indonesia Jakarta Rupiah