问题
I have a grouped dataframe created like so:
my_gb = pandas.read_csv(filepath_or_buffer=my_file_path,
delimiter='\t').groupby(['col1', 'col2', 'col3', 'col4'])
I then call get_group
:
my_row = my_gb.get_group((val1, val2, val3, val4))
And get a MemoryError
.
IIUC, this only returns a view of one row (in my dataset) - how can this cause a memory error?
回答1:
Couldn't get this to work so I did the grouping myself:
data = pandas.read_csv(filepath_or_buffer=my_file_path, delimiter='\t')
grouped = {}
for key, value in data.iterrows():
grouped[(value['col1'], value['col2'], value['col3'], value['col4'])] = value
来源:https://stackoverflow.com/questions/28263073/pandas-get-group-causes-memory-error