English

>>> import pandas as pd >>> dFrameEmt = pd.DataFrame() >>> dFrameEmt Empty DataFrame Columns: [] Index: [] What would happen if we pass 3 columns or 5 columns instead of 4 in the above code?

Advertisements
Advertisements

Question

>>> import pandas as pd
>>> dFrameEmt = pd.DataFrame()
>>> dFrameEmt
Empty DataFrame
Columns: []
Index: []

What would happen if we pass 3 columns or 5 columns instead of 4 in the above code? What is the reason?

Give Reasons
Advertisements

Solution

  • In the given code, if we pass 3 columns or 5 columns instead of 4, an error will occur because the DataFrame does not have matching column labels.
  • The number of column names must be equal to the number of columns in the DataFrame. If the numbers do not match, Pandas cannot create the DataFrame properly.
shaalaa.com
  Is there an error in this question or solution?
Chapter 2: Data Handling using Pandas - I - Intext Questions [Page 41]

APPEARS IN

NCERT Informatics Practices [English] Class 12
Chapter 2 Data Handling using Pandas - I
Intext Questions | Q 8. | Page 41
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×