wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 108

Worksheet time: 54mins

Name
Class
Date
1.

What is the output of the following code? t = (1, 2, 3) + (4, 5) print(t)

a)

(1, 2, 3, 4, 5)

b)

(5, 4, 3, 2, 1)

c)

[1, 2, 3, 4, 5]

d)

(1, 2, 3), (4, 5)

2.

What method is used to remove a specific value from a list?

a)

remove()

b)

pop()

c)

delete()

d)

del

3.

The ______ function returns a new sorted list from any sequence.

a)

sorted

b)

arrange

c)

order

d)

sorter

4.

The update method is used to merge one dictionary into another.

a)

True

b)

False

5.

Which method is used to check if a dictionary contains a specific key?

a)

in

b)

contains()

c)

has_key()

d)

key_check()

6.

The pandas library provides high-level data structures for working with structured and tabular data.

a)

True

b)

False

7.

Which of the following is a mutable object in Python?

a)

String

b)

Tuple

c)

List

d)

None

8.

What will be the output of this code? x = 10; y = 3; print(x // y)

a)

3.33

b)

3

c)

3.0

d)

4

9.

Output of this code: nums = [1, 2, 3] print(sum(nums))

a)

6

b)

5

c)

3

d)

Error

10.

What does the following code print? a = [1,2,3] print(a[::-1])

a)

[3,2,1]

b)

[1,2,3]

c)

[1,3,2]

d)

Error

11.

Output of this code: d = {'a':1, 'b':2} print(d.get('c', 0))

a)

0

b)

None

c)

Error

d)

2

12.

What does the following code return? lst = [1,2,3,4] print(lst.index(3))

a)

2

b)

3

c)

1

d)

Error

13.

The with statement is used to handle ______ safely and ensure they are closed properly.

a)

files

b)

loops

c)

variables

d)

exceptions

14.

Which of the following is **not** a valid input for creating a DataFrame?

a)

A single integer

b)

A dictionary of lists

c)

A NumPy array

d)

A list of dictionaries

15.

What is the output of the following code?

import numpy as np

a = np.array([1, 2, 3])

print(a[1])

a)

1

b)

2

c)

3

d)

Error

16.

What does this code print? import numpy as np a = np.array([[1, 2], [3, 4]]) print(a.shape)

a)

(2,)

b)

(2, 2)

c)

(4,)

d)

Error

17.

Output of the following code? import numpy as np a = np.array([1,2,3]) print(a.dtype)

a)

float64

b)

int64

c)

object

d)

Error

18.

What is the result? import numpy as np a = np.zeros((2,3))

a)

0 0 0
0 0 0

b)

0 0 0

19.

Output of this code? import numpy as np a = np.array([1,2,3,4]) print(np.where(a>2))

a)

(array([2,3]),)

b)

(array([0,1]),)

c)

[3 4]

d)

Error

20.

What does this print? import numpy as np a = np.array([1,2,3,4]) print(np.unique([1,2,2,3,3,4]))

a)

[1 2 3 4]

b)

[1 2 2 3 3 4]

c)

[2 3 4]

d)

Error

21.

What is a key difference between a pandas `Series` and a `DataFrame`?

a)

A `Series` is one-dimensional, while a `DataFrame` is two-dimensional.

b)

A `Series` can contain multiple data types, while a `DataFrame` cannot.

c)

A `DataFrame` does not have indexes, while a `Series` always does.

d)

Both `Series` and `DataFrame` are always empty by default.

22.

Which method allows you to select data from a DataFrame by row and column labels?

a)

loc

b)

iloc

c)

index

d)

slice

23.

What will the following code output? 

```python

import pandas as pd

data = {"A": [1, 2], "B": [3, 4]}

df = pd.DataFrame(data)

print(df.iloc[1])

```

a)

A    2,

  B    4 

b)

A    1, B    3 

c)

[1, 3] 

d)

Error: Invalid index access

24.

What will the following code output? 

```python

import pandas as pd

s = pd.Series([1, 2, 3], index=["a", "b", "c"])

print(s["b"])

```

a)

2

b)

1

c)

"b"

d)

Error: Invalid index access 

25.

What does this code return?

import pandas as pd

df = pd.DataFrame({'A':[1,2,3], 'B':[4,5,6]})

print(df[df['A']>1])

a)

A B
1 2 5
2 3 6

b)

A B
0 1 4

c)

[2,3]

d)

Error

26.

What does this code return?

a)

A B 1 2 5 2 3 6

b)

A B 0 1 4

c)

[2,3]

d)

Error

27.

Output of this code? import pandas as pd df = pd.DataFrame({'A':[1,2,3], 'B':[4,5,6]}) print(df.iloc[1,1])

a)

5

b)

2

c)

4

d)

Error

28.

What does the following code produce? import pandas as pd df = pd.DataFrame({'A':[1,2,3], 'B':[4,5,6]}) print(df.loc[0,'B'])

a)

4

b)

1

c)

0

d)

Error

29.

Which library is typically used to read and parse Excel files in pandas?

a)

openpyxl

b)

pickle

c)

lxml

d)

json

30.

Which pandas method writes a DataFrame to pickle format?

a)

to_pickle()

b)

write_pickle()

c)

to_binary()

d)

pickle_dump()

31.

What will the following code do? import pandas as pd df = pd.read_excel('data.xlsx', sheet_name='Sheet1') print(df.head())

a)

It will read the 'Sheet1' sheet from 'data.xlsx' into a DataFrame and print the first five rows.

b)

It will print the entire contents of 'data.xlsx'.

c)

It will create a new Excel file named 'data.xlsx'.

d)

It will print the last five rows of 'Sheet1' from 'data.xlsx'.

32.

What does this code output? import pandas as pd df = pd.read_csv('data.csv', thousands=',')

a)

Converts numbers like '1,000' to 1000

b)

Treats ',' as delimiter

c)

Reads all values as strings

d)

Error

33.

Output of this code? import pandas as pd df = pd.read_csv('data.csv', skip_blank_lines=True)

a)

Ignores blank lines in the CSV

b)

Reads blank lines as NaN

c)

Error

d)

Deletes CSV

34.

What is the output of this code? import pandas as pd df = pd.read_csv('data.csv', low_memory=False)

a)

Prevents dtype guessing and ensures proper memory usage

b)

Reads CSV in chunks

c)

Converts everything to string

d)

Error

35.

What does this code do? import pandas as pd df = pd.read_sql('SELECT * FROM table1', conn, index_col='ID')

a)

Reads SQL table and sets 'ID' as index

b)

Writes SQL table

c)

Converts SQL table to CSV

d)

Creates a new SQL table

36.

What does this code do?

import pandas as pd

df = pd.read_csv('data.csv', header=None)

print(df.head())

a)

Reads CSV without using the first row as header

b)

Reads CSV using the first row as header

c)

Reads only the first row

d)

Writes CSV without header

37.

How do you remove rows with all NaN values?

df.dropna(how='all', inplace=True)

a)

Drops rows where all values are NaN

b)

Drops any row with NaN

c)

Drops column with NaN

d)

Fills NaN

38.

How can you strip special characters from a string column?

df['col'] = df['col'].str.replace('[^a-zA-Z0-9]', '', regex=True)

a)

Removes all non-alphanumeric characters

b)

Converts to lowercase

c)

Converts to uppercase

d)

Replaces spaces with underscores

39.

Output of this code?

import pandas as pd

df = pd.DataFrame({'A':[1,2,3,4,5]})

Q1 = df['A'].quantile(0.25)

Q3 = df['A'].quantile(0.75)

IQR = Q3 - Q1

df_filtered = df[(df['A'] >= Q1 - 1.5*IQR) & (df['A'] <= Q3 + 1.5*IQR)]

print(df_filtered)

a)

Filters out outliers based on IQR

b)

Keeps only outliers

c)

Drops all rows

d)

Error

40.

How do you replace all infinite values with NaN?

import numpy as np

df.replace([np.inf, -np.inf], np.nan, inplace=True)

a)

Replaces +inf/-inf with NaN

b)

Drops infinite values

c)

Converts to zero

d)

Raises error

41.

What does this code do? df['col'] = df['col'].str.lower()

a)

Converts all strings in the column to lowercase

b)

Converts to uppercase

c)

Strips spaces

d)

Deletes column

42.

How can you remove columns with more than 50% missing values?

a)

Drops columns with more than 50% NaN

b)

Drops rows with >50% NaN

c)

Replaces NaN with 0

d)

Keeps only rows with >50% non-NaN

43.

What does this code produce?

import pandas as pd

df1 = pd.DataFrame({'key':[1,2,3],'A':[10,20,30]})

df2 = pd.DataFrame({'key':[3,4,5],'B':[300,400,500]})

pd.concat([df1, df2], axis=0, ignore_index=True)

a)

Stacks df1 and df2 vertically and resets the index

b)

Stacks horizontally

c)

Performs a merge

d)

Produces an error

44.

What is the result of this code?

import pandas as pd

df = pd.DataFrame({'X':[1,2],'Y':[3,4]})

pd.melt(df, id_vars=['X'])

a)

Keeps 'X' fixed and unpivots 'Y' into long format

b)

Keeps 'Y' fixed and unpivots 'X'

c)

Drops column 'Y'

d)

Produces an error

45.

What does this code do?

import pandas as pd

df1 = pd.DataFrame({'key':[1,2,3],'A':[10,20,30]})

df2 = pd.DataFrame({'key':[2,3,4],'B':[200,300,400]})

pd.merge(df1, df2, how='outer', on='key')

a)

Left join

b)

Inner join

c)

Right join

d)

Outer join

46.

Output of this code?

import pandas as pd

df = pd.DataFrame({'id':[1,1,2,2],'variable':['X','Y','X','Y'],'value':[10,20,30,40]})

df.pivot(index='id', columns='variable', values='value')

a)

Reshapes from wide to long

b)

Reshapes from long to wide format with 'id' as index

c)

Drops column 'value'

d)

Produces an error

47.

What type of join is described?
keeps all rows from df1, adds matching rows from df2

a)

Inner join

b)

Right join

c)

Outer join

d)

Left join

48.

What is the difference between merge and concat?

a)

merge concatenates, concat joins

b)

Both do the same thing

c)

merge deletes duplicates, concat does not

d)

merge joins based on columns or keys, concat stacks DataFrames along axis

49.

How can you reorder levels in a MultiIndex? df.reorder_levels([1,0])

a)

Sorts the index

b)

Switches the positions of the levels

c)

Drops a level

d)

Creates a new column

50.

Что является ключевым отличием между reorder_levels() и swaplevel() в иерархической индексации?

a)

swaplevel() может переупорядочить несколько уровней, в то время как reorder_levels() меняет местами уровни

b)

reorder_levels() может использоваться на неиерархических индексах, в то время как swaplevel() не может

c)

reorder_levels() позволяет произвольное переупорядочение уровней индекса, в то время как swaplevel() только меняет местами два уровня

51.

In a merge() operation, what does the how='outer' parameter do?

a)

Performs a union of the keys from both DataFrames, including all rows from both

b)

Includes only rows with keys present in both DataFrames

c)

Includes rows from the left DataFrame only

d)

Includes rows from the right DataFrame only

52.

Output of this code?

import pandas as pd

arrays = [['A','A','B','B'], [1,2,1,2]]

index = pd.MultiIndex.from_arrays(arrays, names=('letter','num'))

df = pd.DataFrame({'val':[10,20,30,40]}, index=index)

df.loc['A']

a)

Selects all rows where first level of MultiIndex is 'A'

b)

Selects rows where second level is 'A'

c)

Returns columns named 'A'

d)

Produces an error

53.

Output of this code?

import pandas as pd

df = pd.DataFrame({'id':[1,1,2,2],'variable':['X','Y','X','Y'],'value':[10,20,30,40]})

df.pivot(index='id', columns='variable', values='value')

a)

Reshapes from long to wide format with 'id' as index

b)

Reshapes from wide to long

c)

Drops column 'value'

d)

Produces an error

54.

How do you rotate y-axis tick labels?

a)

Rotates y-axis labels by 90 degrees

b)

Rotates x-axis

c)

Rotates plot

d)

Produces an error

55.

How do you change bar width in a bar plot?

df['A'].value_counts().plot.bar(width=0.3)

a)

Sets spacing

b)

Changes color

c)

Produces an error

d)

Sets bar width to 0.3

56.

How do you plot a histogram with normalized frequencies?

df['A'].plot.hist(density=True)

a)

Plots raw counts

b)

Plots histogram normalized to form a probability density

c)

Plots line plot

d)

Produces an error

57.

Which parameters control the spacing between subplots in matplotlib?

a)

width_space and height_space

b)

subplot_space and grid_space

c)

padding_x and padding_y

d)

wspace and hspace

58.

What is the default behavior for connecting points in a matplotlib line plot?

a)

Linear interpolation

b)

Cubic interpolation

c)

Step-wise connection

d)

No connection

59.

Which function is used to set the x-axis label in matplotlib?

a)

set_xlabel()

b)

set_xlim()

c)

set_xticks()

d)

set_title()

60.

Which function is used to create a legend in a plot?

a)

plt.legend()

b)

plt.show_legend()

c)

plt.add_legend()

d)

plt.legend_box()

61.

How can you customize the row and column variables in a seaborn FacetGrid?

a)

Set them using grid.set_rows() and grid.set_cols()

b)

Define them in the facet_vars parameter of FacetGrid()

c)

Use the rows and columns parameters in FacetGrid()

d)

Pass them to the row and col parameters of sns.FacetGrid()

62.

What happens to missing values in a group key during a GroupBy operation? 

a)

They are excluded from the result

b)

They are replaced with zeros

c)

They are included as a separate group

d)

An error is raised

63.

When grouping by multiple keys, what is the type of the first element in the group tuple?

a)

A tuple of key values

b)

A single key value

c)

A pandas DataFrame

d)

A list of grouped rows

64.

What does grouping by a dictionary in pandas achieve?

a)

Maps specific values to group names

b)

Creates hierarchical groups

c)

Applies multiple aggregation functions

d)

Splits groups by index levels

65.

What does the GroupBy object return when iterated over?

a)

Tuples containing the group key and group data

b)

Only the group key

c)

Only the group data

d)

Lists of grouped rows

66.

How do you apply different aggregations to different columns?

df.groupby('Category').agg({'Value':'sum','Score':'max'})

a)

Aggregates Value by sum and Score by max per group

b)

Aggregates all by sum

c)

Aggregates all by max

d)

Produces an error

67.

How do you pivot with multiple index and columns?

pd.pivot_table(df, index=['Category','SubCategory'], columns='Region', values='Value', aggfunc='sum')

a)

Creates hierarchical index and columns, aggregating sum

b)

Creates flat index

c)

Drops Region

d)

Produces an error

68.

How do you pivot with multiple index and columns?

pd.pivot_table(df, index=['Category','SubCategory'], columns='Region', values='Value', aggfunc='sum')

a)

Counts frequency of each Category/SubCategory combination

b)

Sums values

c)

Computes mean

d)

Produces an error

69.

Output of this code?

df.groupby('Category')['Value'].agg(['sum','count','mean'])

a)

Returns sum only

b)

Returns mean only

c)

Produces an error

d)

Returns sum, count, and mean for each category

70.

What does this code produce? import pandas as pd df = pd.DataFrame({'Category':['A','B','A','B'],'Value':[10,20,30,40]}) df.groupby('Category').sum()

a)

Counts rows per category

b)

Averages 'Value' per category

c)

Produces an error

d)

Sums 'Value' for each category

71.

How do you apply multiple aggregations and rename columns?

df.groupby('Category')['Value'].agg(Total='sum', Average='mean')

a)

Produces error in older pandas versions

b)

Aggregates sum only

c)

Aggregates mean only

d)

Returns grouped aggregation with renamed columns

72.

What will pd.to_datetime(["2018-02-29"]) return?

a)

NaT for the invalid date

b)

A datetime object representing February 28, 2018

c)

An empty DataFrame

d)

A ValueError due to an invalid date

73.

When assembling datetime objects using pd.to_datetime(df), what happens if a column is missing (e.g., "hour")?

a)

The missing column is filled with default values (e.g., 0 for hours)

b)

An error is raised due to the missing column

c)

The operation skips rows with missing columns

d)

The DataFrame is converted without the missing field

74.

Which parameter in pd.to_datetime() allows you to set the timezone of the resulting datetime objects? 

a)

utc

b)

tz

c)

timezone

d)

localize

75.

What happens if the freq="infer" parameter fails to determine a consistent frequency?

a)

A ValueError is raised

b)

The index is created without a frequency

c)

The freq parameter defaults to daily

d)

A warning is issued

76.

Which format string correctly parses "12-11-2010 00:00"?

a)

"%d-%m-%Y %H:%M" 

b)

"%Y-%m-%d %H:%M" 

c)

"%d/%m/%Y %H:%M" 

d)

"%m-%d-%Y %H:%M" 

77.

What does the freq="M" parameter specify in pd.date_range()?

a)

Monthly frequency

b)

Minute-based frequency

c)

Monday-based weekly frequency

d)

Milliseconds frequency

78.

Which method converts a pandas period series back to timestamps?

a)

to_timestamp()

b)

to_period()

c)

to_datetime()

d)

to_dates()

79.

How do you forward-fill missing timestamps after resampling?

df.resample('H').ffill()

a)

Fills NaNs using previous available value

b)

Fills with zero

c)

Drops missing

d)

Produces error

80.

How do you compute rolling correlation between two series?

df['value'].rolling(5).corr(df['other'])

a)

Returns covariance

b)

Returns sum

c)

Returns rolling correlation over 5-row window

d)

Produces error

81.

How do you shift values using a time offset?

df['value'].shift(freq=pd.DateOffset(days=3))

a)

Shifts by 3 rows

b)

Shifts values 3 days along the datetime index

c)

Drops rows

d)

Produces error

82.

How do you create a business day date range?

pd.date_range('2020-01-01','2020-01-10', freq='B')

a)

Returns all days

b)

Returns dates skipping weekends

c)

Returns only weekends

d)

Produces error

83.

How do you shift dates with month-end offset?

df.index + pd.offsets.MonthEnd()

a)

Shifts to month start

b)

Shifts each date to the end of month

c)

Produces error

d)

Drops index

84.

How do you shift by custom business days?

df.index + pd.offsets.BDay(5)

a)

Moves 5 calendar days

b)

Moves index 5 business days forward

c)

Produces error

d)

Shifts values

85.

How do you backward-fill missing timestamps after upsampling?

df.resample('H').bfill()

a)

Fills with zero

b)

Fills NaNs using next valid value

c)

Drops rows

d)

Produces an error

86.

How do you shift values by 2 periods with shift?

df['value'].shift(2)

a)

Moves values down 2 rows

b)

Shifts index

c)

Drops rows

d)

Produces an error

87.

What will be the output? s = pd.Series([1,2,3], index=pd.date_range('2023-01-01', periods=3)) s.rolling(2, min_periods=1).sum()

a)

2023-01-01 1.0 2023-01-02 3.0 2023-01-03 5.0 dtype: float64

b)

2023-01-01 NaN 2023-01-02 3 2023-01-03 5 dtype: float64

c)

2023-01-01 1 2023-01-02 2 2023-01-03 3 dtype: int64

d)

Produces an error

88.

What will be the output? df = pd.DataFrame({'value':[1,2,3]}, index=pd.period_range('2023-01-01','2023-03', freq='M')) df.index.to_timestamp()

a)

2023-01-01 1 2023-02-01 2 2023-03-01 3 Freq: MS, Name: value, dtype: int64

b)

2023-01-31 1 2023-02-28 2 2023-03-31 3 dtype: int64

c)

Produces NaNs

d)

Produces an error

89.

What will be the output? s = pd.Series([10,20,30], index=pd.date_range('2023-01-01', periods=3)) s.ewm(span=2).mean()

a)

2023-01-01 10.000000 2023-01-02 16.666667 2023-01-03 26.666667 dtype: float64

b)

2023-01-01 10 2023-01-02 20 2023-01-03 30 dtype: int64

c)

2023-01-01 10 2023-01-02 15 2023-01-03 25 dtype: int64

d)

Produces an error

90.

Which of the following is a valid input for constructing a pd.DatetimeIndex?

a)

A list of ISO-8601 date strings

b)

A dictionary of date strings

c)

An integer index

d)

A set of strings

91.

How do you convert a column to datetime in pandas?

df['date'] = pd.to_datetime(df['date'])

a)

Converts column to string

b)

Converts to numeric

c)

Produces an error

d)

Converts the column 'date' to datetime objects

92.

How do you set a datetime column as index?

df.set_index('date', inplace=True)

a)

Drops the column

b)

Converts index to numeric

c)

Produces an error

d)

Sets 'date' column as index

93.

Output of this code?

df = pd.DataFrame({'A':[1,2,3],'B':[4,5,6]})

df.applymap(lambda x: x**2)

a)

A B 0 1 16 1 4 25 2 9 36

b)

A B 0 1 4 1 2 5 2 3 6

c)

Produces error

94.

Output of this code?

df = pd.DataFrame({'A':[1,2,3]})

df.transform(lambda x: x*3)

a)

A 0 3 1 6 2 9

b)

A 0 1 2 2 3

c)

Produces error

d)

Returns a Series

95.

What does transform return?

a)

Same shape as input DataFrame or Series

b)

Always a single value per column

c)

Always a single scalar

d)

Produces error

96.

What happens if you use map on a DataFrame?

a)

Produces an error; map works on Series

b)

Applies to all elements

c)

Applies only to first column

d)

Converts DataFrame to Series

97.

How do you convert a column to categorical?

df['col'] = df['col'].astype('category')

a)

Converts the column to categorical type

b)

Converts to string

c)

Converts to numeric

d)

Produces an error

98.

What is z-score?

a)

Number of standard deviations a value is from the mean

b)

Difference between median and mean

c)

Ratio of max to min

d)

Range of data

99.

Output of this code?

from scipy.stats import zscore

import pandas as pd

s = pd.Series([1,2,3,4,5])

zscore(s)

a)

array([-1.41421356, -0.70710678, 0., 0.70710678, 1.41421356])

b)

array([1,2,3,4,5])

c)

array([0,0,0,0,0])

d)

Produces error

100.

What will be the output of this code?

import pandas as pd

import numpy as np

df = pd.DataFrame({'A':[1,2,3,4,5], 'B':[5,4,3,2,1]})

df.corr(method='kendall')

a)

A B A 1.0 -1.0 B -1.0 1.0

b)

A B A 1.0 1.0 B 1.0 1.0

c)

Produces error

d)

A B A 0.5 -0.5 B -0.5 0.5 

101.

What will be the output of this code?

s = pd.Series([1,2,2,3,3,3,4,4,4,4])

s.value_counts(normalize=True)

a)

4 0.4 3 0.3 2 0.2 1 0.1 dtype: float64

b)

4 4 3 3 2 2 1 1 dtype: int64

c)

Produces error

d)

1 0.1 2 0.2 3 0.3 4 0.4 

102.

Output of this code?

s = pd.Series([1,2,3,4,5])

np.cumsum((s - s.mean())**2)

a)

Series of cumulative squared deviations

b)

Series of cumulative sums

c)

Series of cumulative means

d)

Produces error

103.

What does this code compute?

df = pd.DataFrame({'X':[1,2,3,4,5], 'Y':[5,4,3,2,1]})

(df.rank() - df.mean())/df.std()

a)

Standardized ranks of each column

b)

Z-scores of original values

c)

Normalized values between 0 and 1

d)

Produces error

104.

What will be the output of this code?

import pandas as pd

import numpy as np

df = pd.DataFrame({

    'date': pd.date_range('2023-01-01', periods=5),

    'val': [1, np.nan, 3, np.nan, 5],

    'cat': ['A','B','A','B','C']

})

df['val'] = df['val'].interpolate(method='linear')

df.groupby('cat')['val'].mean()

a)

cat A 2.0 B 3.0 C 5.0 Name: val, dtype: float64

b)

Produces error

c)

Returns DataFrame instead of Series 

105.

What does this code compute?

df['val'].rolling(2, min_periods=1).apply(lambda x: np.prod(x))

a)

Rolling product of values over a 2-row window, computing even if only 1 value is present

b)

Rolling sum over 2 rows

c)

Cumulative product

d)

Produces error

106.

What is the output?

df['cat'] = df['cat'].astype('category')

df['cat'].cat.codes

a)

 0 0 1 1 2 0 3 1 4 2 dtype: int8

b)

Produces error

c)

Returns original values

d)

Returns strings of categories 

107.

What is the result of this multi-step operation?

df['date'] = pd.to_datetime(df['date'])

df.set_index('date', inplace=True)

df.resample('2D')['val'].sum()

a)

date

2023-01-01 3.0

2023-01-03 3.0

2023-01-05 5.0

Freq: 2D, Name: val, dtype: float64

b)

Produces error

c)

Returns cumulative sum instead

d)

Returns original daily values 

108.

Output of this code?

df['val_z'] = (df['val'] - df['val'].mean()) / df['val'].std()

df.groupby('cat')['val_z'].mean()

a)

cat A 0.0 B 0.0 C 0.0 Name: val_z, dtype: float64

b)

Produces error

c)

Returns original val

d)

Non-zero values