What is the main purpose of the Pandas library in data science?
Think about what you do with tables of data in Python.
Pandas is mainly used to handle and analyze data in tables, making data science tasks easier.
What will be the output of this code?
import pandas as pd df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) print(df)
Look at how DataFrame prints tabular data.
The DataFrame shows columns A and B with their values in rows indexed 0 and 1.
Given the DataFrame below, what is the output of df['B'][1]?
import pandas as pd df = pd.DataFrame({'A': [10, 20, 30], 'B': [100, 200, 300]})
Remember that df['B'] selects column B, then [1] selects the second row.
Column B has values [100, 200, 300]. Index 1 is the second value, 200.
What type of plot will this code produce?
import pandas as pd import matplotlib.pyplot as plt df = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]}) df.plot(x='x', y='y', kind='bar') plt.show()
The kind='bar' argument controls the plot type.
The code creates a bar chart with x on the horizontal axis and y as bar heights.
What error will this code raise?
import pandas as pd df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) print(df['C'])
Check if column 'C' exists in the DataFrame.
Accessing a non-existent column 'C' raises a KeyError in Pandas.