CBSE CS and IP

CBSE Class 11 & 12 Computer Science and Informatics Practices Python Materials, Video Lecture

DataFrame (1 Mark Questions)


  1. DataFrame’s different columns can have data of:
    • Different Type
    • Same Type
    • Both
    • None of these

  2. DataFrame is :
    • Value Mutable
    • Size Mutable
    • Both I & II
    • Immutable

  3. A method that simply renames the index and/or column labels in DataFrame is called
    • rename()
    • reindex()
    • reindex_like()
    • None of these

  4. Fill the blank for getting the below output (consider all the necessary files are imported):
    d1={'Turor':['Tahira','Gurjyot','Anusha','Jacob','Venkat'],
     'Classes':[28,36,41,32,40],
     'Country':['USA','UK','Japan','USA','Brazil'] }
    df1 = pandas.DataFrame(d1)
    df2=df1.pivot_table( ______________________________________ )
    print(df2)
    Output:
    Country         
    Brazil        40
    Japan         41
    UK            36
    USA           60
    

  5. Write the output of the following (consider all the necessary files are imported):
    df=pandas.DataFrame(['A',33,11,2,11,223,11,'A',11,11,11])
    print(df)
    print(df.mode(numeric_only=True)) 
    

  6. Hitesh wants to display the last four rows of the dataframedf and has written the following code :
    df.tail()

    But last 5 rows are being displayed. Identify the error and rewrite the correct code so that last 4 rows get displayed.
  7. Write the command using Insert() function to add a new column in the last place(3rd place) named “Salary” from the list Sal=[10000,15000,20000] in an existing dataframe named EMP already having 2 columns.
  8. Write a small python code to drop a row from dataframe labeled as 0.

No comments:

Post a Comment