मराठी

Carefully observe the following code: import pandas as pd Year1 = {'Q1':5000,'Q2':8000,'Q3':12000,'Q4': 18000} Year2 = {'A' :13000,'B':14000,'C':12000}totSales = {1:Year1,2:Year2} df = pd.DataFrame - Informatics Practices

Advertisements
Advertisements

प्रश्न

Carefully observe the following code:

import pandas as pd
Year1 = {'Q1':5000,'Q2':8000,'Q3':12000,'Q4': 18000} Year2 = {'A' :13000,'B':14000,'C':12000}
totSales = {1:Year1,2:Year2}
df = pd.DataFrame(totSales)
print(df)

Answer the following:

  1. List the index of the DataFrame df
  2. List the column names of DataFrame df.
टीपा लिहा

उत्तर

  1. The index labels of df will include Q1, Q2, Q3, Q4, A, B, and C.
  2. The column names of df will be 1,2.
shaalaa.com
DataFrame
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2022-2023 (March) Sample

संबंधित प्रश्‍न

Case Based

Consider the following DataFram df and answer the following question.

Roll no. Name UT1 UT2 UT3 UT4
1 Prerna Singh 24 24 20 22
2 Manish Arora 18 17 19 22
3 Tanish Geol 20 22 18 24
4 Falguni Jain 22 20 24 20

Write down the command that will give the following output.

Roll no. 6
Name Tanish Geol
UT1 24
UT2 24
UT3 24
UT4 24

dtype: object


Case Based

Consider the following DataFram df and answer the following question.

Roll no. Name UT1 UT2 UT3 UT4
1 Prerna Singh 24 24 20 22
2 Manish Arora 18 17 19 22
3 Tanish Geol 20 22 18 24
4 Falguni Jain 22 20 24 20

Which of the following command will display the column of the DataFrame?


______ function is used to delete an element from series.


Write a single line command to calculate 10% from ‘sale’ column from dataframe df and assign to new column ‘Commission’.


Which one is the incorrect option to add a new column using insert() 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?


Which of the following can be used to specify the data while creating a DataFrame?


Assertion (A): DataFrame has both a row and column index.

Reasoning (R): A DataFrame is a two-dimensional labelled data structure like a table of MySQL.


Consider the given DataFrame ‘Stock’:

  Name Price
0 Nancy Drew 150
1 Hardy boys 180
2 Diary of a wimpy kid 225
3 Harry Potter 500

Write suitable Python statements for the following:

  1. Add a column called Special_Price with the following data: [135,150,200,440].
  2. Add a new book named ‘The Secret' with a price of 800.
  3. Remove the column Special_Price.

Mr. Som, a data analyst has designed the DataFrame df that contains data about Computer Olympiad with ‘CO1’, ‘CO2’, ‘CO3’, ‘CO4’, and ‘CO5’ as indexes shown below. Answer the following questions:

  School Tot_students Topper First_Runnerup
CO1 PPS 40 32 8
CO2 JPS 30 18 12
CO3 GPS 20 18 2
CO4 MPS 18 10 8
CO5 BPS 28 20 8
  1. Predict the output of the following python statement:
    i. df.shape
    ii. df[2:4]
  2. Write a Python statement to display the data of the Topper column of indexes CO2 to CO4.
    OR
    Write a Python statement to compute and display the difference of data of the Tot_students column and First_Runnerup column of the above given DataFrame.

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×