Reputation: 2917
Have anyone known the total columns in pandas, python? I have just created a dataframe for pandas included more than 20,000 columns but I got memory error.
Thanks a lot
Upvotes: 1
Views: 4150
Reputation: 1223
There isn't a set maximum of columns - the issue is that you've quite simply run out of available memory on your computer, unfortunately.
One way to fix it is to get some more memory - but that obviously isn't a solid solution in the long run (might be quite expensive, too). If the only thing you did was to create the dataframe and that generated the error, there's very little else you can do to solve that particular issue - Although you could break your "big" dataframe up into smaller dataframes, and work on them one at a time - possibly even writing them to a file when they're not needed so they don't take up RAM-memory.
You might want to take a look at improving your algorithm so it consumes less memory - take a look at this page, it contains some good info on memory allocation in Python. This question on Stack Overflow also has some good tips for profiling your memory-usage!
Upvotes: 1
Reputation: 136306
You get an out of memory error because you run out of memory, not because there is a limit on the number of columns.
Upvotes: 6