[英]Turn correlating rows values from positive to negative pandas dataframe
trying to write a script to process some invoices we to make things a bit easier.尝试编写一个脚本来处理一些发票,我们让事情变得更容易一些。 I have a data frame with 25 x columns and 725k x rows
我有一个包含 25 x 列和 725k x 行的数据框
very simply.很简单。
if the value in a column is negative then the value in the same row in column next to it is negative?如果一列中的值是负数,那么它旁边的同一行中的值是负数吗?
for i in solar['Usage']:
if i == -i:
i in solar['Value']
print('-'+ str(i))
i wrote this and it only turns the very bottom number of the entire data frame to a negative.我写了这个,它只会把整个数据框的最底部的数字变成负数。
value Usage
1 23
23 -43
23 34
34 23
if a value in usage is negative then the corresponding value in the same row has to be negative.如果使用中的值为负,则同一行中的相应值必须为负。
cheers for your help.为你的帮助喝彩。
just starting out.刚开始。
have looked everywhere.到处都看过。
Try this code:试试这个代码:
solar['Usage'] = np.where(solar['value']<0, solar['Usage']*-1, solar['Usage'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.