Considering I have the following dataframe
import pandas as pd
purchase_1 = pd.Series({'Name': 'Chris',
'Item Purchased': 'Dog Food',
'Cost': 22.50})
purchase_2 = pd.Series({'Name': 'Kevyn',
'Item Purchased': 'Kitty Litter',
'Cost': 2.50})
purchase_3 = pd.Series({'Name': 'Vinod',
'Item Purchased': 'Bird Seed',
'Cost': 5.00})
df = pd.DataFrame([purchase_1, purchase_2, purchase_3], index=['Store 1', 'Store 1', 'Store 2'])
what is the difference between df_slice = df.loc['Store 1', 'Cost']
and df_slice = df['Cost']['Store 1']
? When I change the value of these slices, the original dataframe is modified in both cases. Although when I try to change the value of the slice from the first option, it raises an error when ran in Jupyter Notebook: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.