Puzzle 13: A 10% Discount

Let's modify a value in a pandas DataFrame puzzle.

We'll cover the following

Guess the output

Try to guess the output of the code below:

Press + to interact
import pandas as pd
df = pd.DataFrame([
['Bugs', True, 72.3],
['Daffy', False, 30.7],
['Tweety', True, 23.5],
['Elmer', False, 103.9],
], columns=['Customer', 'Member', 'Amount'])
df[df['Member']]['Amount'] *= 0.9
print(df)

Quiz

Q

What is the output of the code above?

A)
  Customer  Member  Amount
0     Bugs    True    72.3
1    Daffy   False    30.7
2   Tweety    True    23.5
3    Elmer   False   103.9
B)
  Customer  Member  Amount
0     Bugs    True    72.3
1    Daffy   False    30.7
2   Tweety    True    23.5
3    Elmer   False   103.9

main.py:9: SettingWithCopyWarning
C)
SettingWithCopyWarning
D)

RunTimeError

Get hands-on with 1300+ tech skills courses.