Ch 2 Python Pandas
Ch 2 Python Pandas
CH – 2 PYTHON PANDAS
1. Name some descriptive statistic functions used with dataframes.
Some of the descriptive statistic functions used with dataframes:
min(), max(), mode(), mean(), median(), count(), sum(), quantile() and var()
2. To, calculate statistical values for each row, the axis argument’ should be _________?
The axis argument must be ‘0’ to calculate statistical values for each row.
3. What are quantile and quartiles?
a. Quantiles are points in a distribution that relate to the rank order of values in that distribution. The
quantile of the median is 0.5, by definition.
b. Quartiles are the multiples of 0.25, with three measures of spread i.e. the Lower Quartile (Q1),
Upper Quartile (Q2) and the Interquartile Range (IQR).
4. What does quantile() do?
The quantile() function returns the values at the given quantiles over requested axis.
5. Name pivoting functions available for dataframes.
Pivoting functions available for dataframes are:
a. pivot()
Syntax: <DataFrame>.pivot(index = <column name>, columns = <column name>, values = <column
name>)
b. pivot_table()
Syntax: <DataFrame>.pivot_table(index = , columns = , values = , aggfunc = )
6. What is the use of aggfunc argument in pivot_table( )?
The ‘aggfunc’ argument in the pivot_table() function contains the function as per which the data is to
be aggregated. By default it is mean.
7. What does hist( ) do?
The hist() function helps to plot a histogram and show the underlying frequency distribution of a set of
continuous data.
8. Name some function-application functions.
Some function-application functions are:
a. pipe()
b. apply()
c. applymap()
d. groupby()
e. transform()
9. When should pipe( ) be preferred over sandwiching of function call?
When there are more than two levels of sandwiching, then the pipe() function must be preferred.
10. What does groupby( ) do?
The groupby() function is used to group the data on the basis of a particular column or multiple
columns.
Syntax: <DataFrame>.groupby(by = , axis = )