0

This is my first time asking a question so forgive me if I made some mistakes in asking.

I'm currently doing Guided Project: Exploring Ebay Car Sales Data in DataQuest. The number 5 task is a bit tricky. It tells me to make the column autos["date_crawled"] into a int dtype. So I just decided to take the date without dash and the time.

I just used what they taught me in datacleaning course.

This is my code:

autos["date_crawled"]=(autos["date_crawled"]
                       .str.replace('-','')
                       .str.split().str[0]
                       .astype(int))

autos- whole data , date_crawled(before) - 2016-04-04 13:38:56 , date_crawled(after) - 20160404

But after running the code, it gives me the warning "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 DATAQUEST" which didn't happened when they taught me the method.

I wanna know why it occurs. Thanks a lot.

MrFapoh
  • 23
  • 5
  • Does this answer your question? [How to deal with SettingWithCopyWarning in Pandas?](https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas) – GPhilo Feb 04 '20 at 12:02
  • The source of the error is not in the showed code. Somewhere, you do some filtering on `autos`, in the style `autos = autos[some_condition]`. This creates a slice over the original dataset. When you try to assign values to the slice, you get the error you show. – GPhilo Feb 04 '20 at 12:06

0 Answers0