Avatar of Maria Qureshi
Maria Qureshi

asked on 

Why is this code wrong?

bins = [0, 10, 20, 30, 40, 50, 60, 70, 80]

df['AgeBin'] = pd.cut(df['Age'], bins)

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-16-0750c69cbf65> in <module>()
      1 bins = [0, 10, 20, 30, 40, 50, 60, 70, 80]
      2
----> 3 df['AgeBin'] = {pd.cut(df['Age'], bins)}

NameError: name 'pd' is not defined
Python

Avatar of undefined
Last Comment
Flabio Gates

8/22/2022 - Mon