1

When I use pandas DataFrame, occuring the Memory Error.

data's row is 200000 and column is 30.(type: list) fieldnames1 has columns name.(type:list)

Error occured in:

df = pd.DataFrame(data,columns=[fieldnames1])

what should I do? (python version 2.7 32bit)

EdChum
  • 294,303
  • 173
  • 671
  • 486
홍형기
  • 53
  • 2
  • 8
  • You ran out of RAM. Try to use less data for testing and a combination of more RAM, a 64bit OS and 64bit Python. – Klaus D. Jul 06 '15 at 09:03
  • Any reason you don't use 64-bit version of python? Also storing lists in a df is a bit strange – EdChum Jul 06 '15 at 09:13

2 Answers2

3

As indicated by Klaus, you're running out of memory. The problem occurs when you try to pull the entire text to memory in one go.

As pointed out in this post by Wes McKinney, "a solution is to read the file in smaller pieces (use iterator=True, chunksize=1000) then concatenate then with pd.concat".

Community
  • 1
  • 1
Julien Marrec
  • 9,670
  • 4
  • 36
  • 57
-1

You can try this line of code:

data=pd.DataFrame.from_csv("train.csv")

This is an alternate of read.csv but it returns Data frame object without giving any memory error P.S the size of the training data is around 73 mb

Javeria
  • 41
  • 1
  • 7