2024-09-28 01:30:35 发布
网友
我有一个来自csv文件的数据帧,我绘制了它。你知道吗
它看起来像这样:
我想将'W'列的值乘以1000,以便使值为1600而不是1.6。如何在代码中实现这一点?你知道吗
'W'
我正在尝试mul函数,但它不起作用:
mul
xcolumn_list1 = ['W'] xcolumn_list1.mul(1000) geyser_June_e2[xcolumn_list1].plot() plt.show()
df=pd.DataFrame({"W":[1,2,3,4,5]}) df*=1000 print(df) W 0 1000 1 2000 2 3000 3 4000 4 5000
或者
df=pd.DataFrame({"W":[1,2,3,4,5]}) df.loc[:,"W"]=df.loc[:,"W"]*1000 print(df) W 0 1000 1 2000 2 3000 3 4000 4 5000
如果您有多列并且只想将某些列的值相乘
不能对列表使用.mul()。我认为在['W']之前缺少了dataframe名称,添加dataframe名称,.mul函数可以正常工作,即如果geyser_June_e2是dataframe名称,那么
.mul()
.mul
geyser_June_e2
xcolumn_list1 = geyser_June_e2['W'] xcolumn_list1.mul(1000)
在你的例子中,你想要绘制数据,就像John Galt说的那样,你可以直接乘以1000,然后绘制数据
xcolumn_list1 = ['W'] geyser_June_e2[xcolumn_list1] *= 1000 geyser_June_e2[xcolumn_list1].plot() plt.show()
或者
如果您有多列并且只想将某些列的值相乘
不能对列表使用
.mul()
。我认为在['W']之前缺少了dataframe名称,添加dataframe名称,.mul
函数可以正常工作,即如果geyser_June_e2
是dataframe名称,那么在你的例子中,你想要绘制数据,就像John Galt说的那样,你可以直接乘以1000,然后绘制数据
相关问题 更多 >
编程相关推荐