2

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)

2
  • You ran out of RAM. Try to use less data for testing and a combination of more RAM, a 64bit OS and 64bit Python. Commented Jul 6, 2015 at 9:03
  • Any reason you don't use 64-bit version of python? Also storing lists in a df is a bit strange Commented Jul 6, 2015 at 9:13

2 Answers 2

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".

Sign up to request clarification or add additional context in comments.

Comments

-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.