使用Panda中的现有列在dataFrame中创建新列

时间:2015-09-09 19:16:39

标签: python pandas

我有来自csv文件的数据框:

from flask import request
product_id = request.json['product_id']
url = request.json['url']
website_name = request.json['website_name']

我正在尝试按m_srcaddr进行分组,并将它们的m_fwd_bytes和m_rev_bytes之和除以新列中的1000,名为total_fwd_size和total_rev_size

    time    m_srcaddr   log_type    m_type  m_fwd_bytes m_rev_bytes
1   1441590784  172.19.139.165  closed  10  295 146
11  1441590785  172.19.139.174  closed  10  441 183
65  1441590792  172.19.139.166  closed  10  441 200
68  1441590792  172.19.139.166  closed  10  3423    461
73  1441590792  172.19.139.172  closed  10  441 379
76  1441590792  172.19.139.172  closed  10  3423    789
77  1441590792  172.19.139.166  closed  10  441 463
81  1441590792  172.19.139.166  closed  10  3423    963
82  1441590793  172.19.139.173  closed  10  295 168
85  1441590793  172.19.139.172  closed  10  4929    542
89  1441590793  172.19.139.166  closed  10  5135    799
93  1441590793  172.19.139.166  closed  10  4929    510
96  1441590794  172.19.139.166  closed  10  0   198
98  1441590794  172.19.139.167  closed  10  0   455
100 1441590794  172.19.139.166  closed  10  4945    495

这不起作用,因为NaN即将推出新创建的列。有没有最好的办法做同样的事情?

0 个答案:

没有答案