Alex Luya Alex Luya - 1 month ago 48
Python Question

How to set/get pandas.DataFrame to/from redis?

After setting DatFrame to redis,then get from it,redis returns a string,and I can't figure out a way to convert this str to DataFrame,so how to do these two appropriately?Thanks.

Answer

set:

redisConn.set("key", df.to_msgpack(compress='zlib'))

get:

pd.read_msgpack(redisConn.get("key"))