【发布时间】:2021-09-01 02:56:09
【问题描述】:
我有一个将华氏温度转换为摄氏度的功能
def temp_to_celcius(temp):
return ((temp-32.0)*5.0)/9.0
它从包含华氏温度列表的 DataFrame 中获取一列,例如:
table['temp'][:5]
0 30.0
1 30.0
2 30.0
3 30.0
4 30.0
Name: temp, dtype: float64
并返回修改后的温度列表:
temp_to_celcius(table['temp'][:5])
0 -1.111111
1 -1.111111
2 -1.111111
3 -1.111111
4 -1.111111
Name: temp, dtype: float64
但是我怎样才能修改我的函数,以便将第二列中的 values 作为这样的列表返回:
[-1.11111111 -1.11111111 -1.11111111 -1.11111111 -1.11111111]
但不是带有温度列表的索引列?
【问题讨论】:
标签: python pandas list dataframe function