Python Pandas MemoryError

前端 未结 2 1070
余生分开走
余生分开走 2021-01-14 22:14

I have those packages installed:

python: 2.7.3.final.0
python-bits: 64
OS: Linux
machine: x86_64
processor: x86_64
byteorder: little
pandas: 0.13.1
         


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-14 23:07

    Try generating the _id field with DataFrame.apply call:

    def apply_id(x):
        x['_id'] = "{}_{}_{}".format(x['Store'], x['Dept'], x['Date_Str'])
        return x
    
    df_train = df_train.apply(apply_id, 1)
    

    When using apply the id generation is performed per row resulting in minimal overhead in memory allocation.

提交回复
热议问题