0

I have a dataframe that looks like this:

Time  y1    y2
100   130  44.57
200   130  42.23
300   130  42.83

I am simply trying to convert column Time from s into minutes, and make an operation between column y1 and y2. However I keep getting a warning message: 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

#Both this operations give a warning error: 
df1['Time'] =  df1['Time']/60)
df1['y1/y2'] = (df1['y2']-df1['y1'])/(df1['y2'])

#This is what I tried:
#df1.loc[:, 'New'] = df1.loc[:,'Time'].apply(lambda x: df1['Time']/60)

#df1['y1/y2'] = (df1['y2']-df1['y1'])/(df1['y2']).copy()

#What I'm trying to do is very simple but I keep getting the error message: 

#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

Thank you in advance!

Klaus78
  • 11,648
  • 5
  • 32
  • 28

1 Answers1

0

Add this line before you do your calculations:

df1 = df1.copy()