Creating DataFrames

These quizzes are based on Creating DataFrames in Pandas are divided into 10 questions, along with the correct answers and justifications.

Last Updated :
Discuss
Comments

Question 1

What is the default data type for a column in a pandas DataFrame if not specified?

  • int

  • float

  • Object

  • None

Question 2

Which of these data structures cannot directly create a DataFrame?

  • Dictionary

  • NumPy array

  • Python list

  • Set

Question 3

When creating a DataFrame from a NumPy array, how do you name the columns?

  • Use columns argument

  • Use col_names argument

  • It is not possible

  • Use headers argument

Question 4

What happens if column names are not provided when creating a DataFrame from a dictionary?

  • Throws an error

  • Uses numerical indices

  • Automatically names columns as col1, col2, etc.

  • None of the above

Question 5

How can you create an empty DataFrame?

  • pd.DataFrame()

  • pd.DataFrame(None)

  • pd.DataFrame([])

  • All of the above

Question 6

What does the index argument specify when creating a DataFrame?

  • Row indices

  • Column indices

  • Values

  • None of the above

Question 7

What does the index argument specify when creating a DataFrame?

  • Row indices

  • Column indices

  • Values

  • None of the above

Question 8

What will be the default index of a DataFrame created from a dictionary?

  • 0, 1, 2, ...

  • None

  • Keys of the dictionary

  • None of the above

Question 9

How can you specify the data type for each column in a DataFrame?

  • Using dtype argument

  • Using columns argument

  • Using data_type argument

  • Using types argument

Question 10

What happens if the lengths of columns are unequal when creating a DataFrame from a dictionary?

  • Throws a ValueError

  • Truncates longer columns

  • Pads shorter columns with NaN

  • None of the above

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion