Error that I never seen in previous sections

Is my code wrong?? but I get the output and also get the error… maybe i should say warning? Never seen this before? what does it mean? Thank you!!

Screen Link: https://app.dataquest.io/m/348/guided-project%3A-clean-and-analyze-employee-exit-surveys/5/verify-the-data

My Code:

#extract year only and change datatype to float
pattern=r'([2][0-9]{3})'
dete_resignations['cease_date']=dete_resignations['cease_date'].str.extract(pattern).astype(float)

What actually happened:

/dataquest/system/env/python3/lib/python3.4/site-packages/ipykernel/__main__.py:3: FutureWarning: currently extract(expand=None) means expand=False (return Index/Series/DataFrame) but in a future version of pandas this will be changed to expand=True (return DataFrame)
  app.launch_new_instance()
/dataquest/system/env/python3/lib/python3.4/site-packages/ipykernel/__main__.py:3: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  app.launch_new_instance()
1 Like

I have deleted my previous answer because I have realized what you got was actually warnings and not errors.

For the “SettingWithCopyWarning”, I’d recommend checking this Dataquest Blog post.

The first warning says that in the version of pandas that is used (which is obviously an old version), the default for “expand” clause is “False”. In newer versions, it’s set to “True”. I’d recommend doing the following:

dete_resignations["cease_date"] = dete_resignations["cease_date"].str.extract(pattern, expand=True)
dete_resignations["cease_date"] = dete_resignations["cease_date"].astype(float)
2 Likes

Thank you for explaining. I tried your code,I got error as well.

It is said that contains() got an unexpected keyword argument ‘expand’.

Hello,
I did not use contains() there, I used extract(). Are you sure about that?

oh i see the problem!!! Thank you!

It works after i changed to extract!!!

I’m glad to have helped! :innocent: