如何在 pandas 中的列之间进行操作以避免警告消息 'Try using .loc[row_indexer,col_indexer] = value instead'

How to make operations between columns in pandas so to avoid warning message 'Try using .loc[row_indexer,col_indexer] = value instead'

我有一个如下所示的数据框:

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

我只是想将 Time 列从 s 转换为分钟,并在 y1 和 y2 列之间进行运算。但是我不断收到一条警告消息: 试图在 DataFrame 的切片副本上设置一个值。 尝试使用 .loc[row_indexer,col_indexer] = value 代替

#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

提前致谢!

在计算之前添加这一行:

df1 = df1.copy()