pandas_streaming.df.dataframe_io#

pandas_streaming.df.dataframe_io.read_zip(zipfilename, zname=None, **kwargs)[source][source]#

Reads a dataframe from a zip file. It can be saved by to_zip().

Parameters:
Returns:

pandas.DataFrame or numpy.ndarray

pandas_streaming.df.dataframe_io.to_zip(df, zipfilename, zname='df.csv', **kwargs)[source][source]#

Saves a Dataframe into a zip file. It can be read by read_zip().

Parameters:
Returns:

zipfilename

Saves and reads a dataframe in a zip file

This shows an example on how to save and read a pandas.DataFrame directly into a zip file.

<<<

import pandas
from pandas_streaming.df import to_zip, read_zip

df = pandas.DataFrame([dict(a=1, b="e"), dict(b="f", a=5.7)])

name = "dfs.zip"
to_zip(df, name, encoding="utf-8", index=False)
df2 = read_zip(name, encoding="utf-8")
print(df2)

>>>

         a  b
    0  1.0  e
    1  5.7  f

Saves and reads a numpy array in a zip file

This shows an example on how to save and read a numpy.ndarray directly into a zip file.

<<<

import numpy
from pandas_streaming.df import to_zip, read_zip

arr = numpy.array([[0.5, 1.5], [0.4, 1.6]])

name = "dfsa.zip"
to_zip(arr, name, "arr.npy")
arr2 = read_zip(name, "arr.npy")
print(arr2)

>>>

    [[0.5 1.5]
     [0.4 1.6]]