Forum

UCLU-3 Unsupervised...
 
Notifications
Clear all

UCLU-3 Unsupervised Learning. Market Basket Analysis Part 2  

   RSS

0

Hi

When I am trying to run the code below, i get the following error message.   What should I do?

# These 2 features will be used to group the data.
# Description is used instead of StockID as it is human readable when we analyze the assoc rules later
tf_f['Description'] = tf_f['Description'].str.strip()
tf_f['InvoiceNo'] = tf_f['InvoiceNo'].astype(str)

 

: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:  https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy 
  tf_f['Description'] = tf_f['Description'].str.strip()
:4: 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:  https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy 
  tf_f['InvoiceNo'] = tf_f['InvoiceNo'].astype(str)
1 Answer
0

Hey @timpanister! The message is a warning, not an error.

Instead of 

tf_f['Description'] = tf_f['Description'].str.strip()

It wants us to do

tf_f.loc[:,'Description'] = tf_f['Description'].str.strip()

 

You can read about it here. Overall it's a minor warning.

Share:

Delete your account