0% found this document useful (0 votes)
39 views

Tutorial

This document contains a 20 question quiz about NumPy and Pandas. The questions cover topics like: - Using DataFrame describe() to get statistical data - Selecting columns from a DataFrame using loc and iloc - Value counts in a DataFrame column - Filtering rows based on column values - Data types of DataFrame columns - Length of DataFrame columns - Loading data from files into DataFrames - Creating and accessing Series and DataFrames

Uploaded by

subodhaade2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Tutorial

This document contains a 20 question quiz about NumPy and Pandas. The questions cover topics like: - Using DataFrame describe() to get statistical data - Selecting columns from a DataFrame using loc and iloc - Value counts in a DataFrame column - Filtering rows based on column values - Data types of DataFrame columns - Length of DataFrame columns - Loading data from files into DataFrames - Creating and accessing Series and DataFrames

Uploaded by

subodhaade2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Python Tutorial 6

Numpy and Pandas


Quiz

1.Which of the returns the statistical data about the numerical


columns in the data frame df?

1. print(df.describe())
2. print(df.stats())
3. print(describe(df))
4. print(stats(df))

2.Which of the following is/are used to get the columns named


‘clmn1’ and ‘clmn3’ from the data frame df?

1. print(df.loc['cl3','cl5'])
2. print(df.loc[['cl3','cl5']])
3. print(cls.iloc[['cl3','cl5']])
4. print(df.iloc['cl3','cl5'])

3.What does the below code do?

df.clmn.value_counts()

1. Return the number of values in the column


2. Return the frequency of occurrences of each unique value
3. Return the number of rows
4. None of the above
4.What is the output of the below code?

df.loc[df.clmn==10,:]

1. Return the columns clmn where the value is equal to 10


2. Return all the columns of the data frame df withe value equals 10
3. Return all the columns clmn and the first 10 rows
4. None of the above

5.What is the output of the following code?

print(df.iloc[2:5])

1. prints the 2nd, 3rd,4th,5th columns of the dataframe df


2. prints the 2nd, 3rd,4th columns of the dataframe df
3. prints the 2nd, 3rd,4th rows of the dataframe df
4. prints the 2nd, 3rd,4th,5th rows of the dataframe df

6.Which of the following is the correct way to create a data frame?

1. pandas.DataFrame( data, index, columns, dtype, copy)


2. pandas.Dataframe( data, index, columns, dtype, copy)
3. pandas.dataFrame( data, index, columns, dtype,)
4. pandas.dataframe( data, index, columns, dtype)

7.Which of the following can be stored in a dataframe?

1. a two-dimensional ndarray
2. lists, dictionaries, or Series.
3. Pandas DataFrame
4. All the above

8.Which of the following commands return the data type of the


values in each column in the data frame df?

1. print(df.dtype)
2. print(dtypes(df))
3. print(df.dtypes)
4. None of the above

9.Given a dataset named ‘data’ containing the 5 columns and 10


rows, find the output of the below code?

print(len(data.columns))

1. 5
2. 10
3. 15
4. 50

10.From which of the following files, pandas can read data?

1. JSON
2. Excel
3. HTML
4. All the above

11.Which of the following features is not provided by the Pandas


module?

1. Merge and join the data sets


2. Filter data using the condition
3. Plot and visualize the data
4. None of the above

12. What is the correct syntax to create a Pandas Series from a Python
list?

1. pd.createSeries(mylist)
2. pd.Series(mylist)
3. pd.getSeries(mylist)

13.What is the correct syntax to return the first value of a Pandas


Series?

1. myseries[0]
2. myseries.get(0)
3. get(myseries,0)

14.What is the correct syntax to add the labels "x", "y", and "z" to a
Pandas Series?

1. pd.Series(mylist, labels = ["x", "y", "z"]


2. pd.Series(mylist, index = ["x", "y", "z"]
3. pd.Series(mylist, names = ["x", "y", "z"]

15.What is the correct syntax to create a Pandas DataFrame?

1. pd.dataframe(data)
2. pd.DataFrame(data)
3. pd.df(data)
16.What is the correct syntax to return the first row in a Pandas
DataFrame?

1. df.loc[0]
2. df[0]
3. df.get[0]

17.What is the correct syntax to return both the first row and the
second row in a Pandas DataFrame?

1. df.[[0-1]]
2. df.[[0, 1]]
3. df.loc[[0, 1]]
4. df.loc[[0-1]]

18.What is the correct Pandas function for loading CSV files into a
DataFrame?

1. ReadFile()
2. read_csv()
3. read_file()
4. ReadCSV()

19.What is the correct Pandas function for loading JSON files into a
DataFrame?

1. ReadJSON()
2. ReadFile()
3. read_file()
4. read_json()
20.What is the correct syntax to load a Python Dictionary called "data"
into a Pandas DataFrame?

1. pd.ReadJSON(data)
2. pd.load_json(data)
3. pd.DataFrame(data)

You might also like