Pandas DataFrames: Exercises


1. Creating a Pandas DataFrame. In Python, Pandas is a library commonly used for data manipulation and analysis. You can create a Pandas DataFrame by importing the Pandas library and using the pandas.DataFrame() constructor.

For example, you can create a DataFrame to store information about students like this: import pandas as pd; df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [20, 22, 21]}).


# Import the Pandas library import pandas as pd # Create a Pandas DataFrame with student information df = pd.DataFrame(___) # Print the DataFrame print(df) # Import the Pandas library import pandas as pd # Create a Pandas DataFrame with student information df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [20, 22, 21]}) # Print the DataFrame print(df) test_object("df") success_msg("You have correctly created a Pandas DataFrame with student information.")
To create a Pandas DataFrame, import Pandas and use pandas.DataFrame() with a dictionary containing column names and data.

Previous Exercise Next Exercise