小编Van*_*ssa的帖子

使用熊猫添加带有“ to_csv”的注释

我使用方法保存一个数据框,to_csv输出如下所示:

2015 04 08 0.0 14.9
2015 04 09 0.0  9.8
2015 04 10 0.3 23.0
Run Code Online (Sandbox Code Playgroud)

但我需要对此输出进行一些修改,我需要添加一个注释和一个具有恒定值且大小与其他列相同的列。我需要获得这样的输出:

#Data from the ...
#yyyy mm dd pcp temp er
2015 04 08 0.0 14.9 0
2015 04 09 0.0  9.8 0
2015 04 10 0.3 23.0 0
Run Code Online (Sandbox Code Playgroud)

有谁知道这是怎么做到的吗?

python pandas

5
推荐指数
1
解决办法
1562
查看次数

用python减去不同数据框的两列

我有两个DataFrame,df1:

     Lat1         Lon1     tp1
0   34.475000  349.835000   1
1   34.476920  349.862065   0.5
2   34.478833  349.889131   0
3   34.480739  349.916199   3
4   34.482639  349.943268   0
5   34.484532  349.970338   0
Run Code Online (Sandbox Code Playgroud)

和df2:

      Lat2         Lon2    tp2
0   34.475000  349.835000   2
1   34.476920  349.862065   1
2   34.478833  349.889131   0
3   34.480739  349.916199   6
4   34.482639  349.943268   0
5   34.484532  349.970338   0
Run Code Online (Sandbox Code Playgroud)

我想减去(tp1-tp2)列并创建一个新数据框,其列为Lat1,lon1,tp1-tp2。有人知道我该怎么做吗?

dataframe python-2.7 pandas

1
推荐指数
1
解决办法
7745
查看次数

标签 统计

pandas ×2

dataframe ×1

python ×1

python-2.7 ×1