module df.dataframe_io

Short summary

module pandas_streaming.df.dataframe_io

Saves and reads a dataframe into a zip file.

source on GitHub

Functions

function

truncated documentation

read_zip

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

to_zip

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

Documentation

Saves and reads a dataframe into a zip file.

source on GitHub

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

Reads a dataframe from a zip file. It can be saved by read_zip.

Parameters
Returns

pandas.dataframe or numpy.array

source on GitHub

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

Saves a Dataframe into a zip file. It can be read by to_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]]

source on GitHub