Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
93 views
in Technique[技术] by (71.8m points)

python - Where to store a large pandas dataframe (consumed by a webapp)?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Where did the data come from to populate the dataframe?

If it was a database for example, you could just grab the data the user needed at that time rather than putting all your data into memory.

On the other hand, if your data didn't come from a database then that would be my first suggestion. Put the data into a database, these things were built for that purpose. You can create a dataframe from an sql query (pandas.read_sql).

If you really must have 5g of data in memory, then perhaps an in memory database would be suitable. For this purpose Redis comes to mind.

You could either pickle the dataframe and store the whole thing as an object, or you could break it down to records and store the individually and pull down only the data the user requests. This would remove the requirement for your application to store 5g of data in memory all the time.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...