合并数据帧内存效率问题熊猫

时间:2017-05-03 15:59:36

标签: python pandas optimization

我正在尝试将这个确切的命令用于我的代码

merging files based on column coordinates of two files in python

但我的系统会冻结(可能是因为我有~315,000行),还有更好的方法吗? 下面是我的代码:

new_df = df.merge(gene_df, how='outer', on ='chrm')
new_df = new_df[(new_df.start_x>=df.start_y) & (df.end_x<=df.end_y)]
print (new_df.head(10))

1 个答案:

答案 0 :(得分:1)

只需使用new_df字段即可。您的逻辑使用之前合并的原始df中的字段。仔细看看你的链接问题。跨数据框架的这种逻辑很难运行!

new_df = new_df[(new_df.start_x >= new_df.start_y) & (new_df.end_x <= new_df.end_y)]
相关问题