Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2"""
3@file
4@brief Dummy datasets.
5"""
6from pandas import DataFrame
7from ..df import StreamingDataFrame
10def dummy_streaming_dataframe(n, chunksize=10, asfloat=False, **cols):
11 """
12 Returns a dummy streaming dataframe
13 mostly for unit test purposes.
15 :param n: number of rows
16 :param chunksize: chunk size
17 :param asfloat: use random float and not random int
18 :param cols: additional columns
19 :return: a @see cl StreamingDataFrame
20 """
21 if asfloat:
22 df = DataFrame(dict(cfloat=[_ + 0.1 for _ in range(0, n)], cstr=[
23 "s{0}".format(i) for i in range(0, n)]))
24 else:
25 df = DataFrame(dict(cint=list(range(0, n)), cstr=[
26 "s{0}".format(i) for i in range(0, n)]))
27 for k, v in cols.items():
28 df[k] = v
29 return StreamingDataFrame.read_df(df, chunksize=chunksize)