pandas 1.4.2

Parameters
makeCustomDataframe(nrows, ncols, c_idx_names=True, r_idx_names=True, c_idx_nlevels=1, r_idx_nlevels=1, data_gen_f=None, c_ndupe_l=None, r_ndupe_l=None, dtype=None, c_idx_type=None, r_idx_type=None)

Parameters

nrows, ncols - number of data rows/cols :
c_idx_names, idx_names - False/True/list of strings, yields No names , :

default names or uses the provided names for the levels of the corresponding index. You can provide a single string when c_idx_nlevels ==1.

c_idx_nlevels - number of levels in columns index. > 1 will yield MultiIndex :
r_idx_nlevels - number of levels in rows index. > 1 will yield MultiIndex :
data_gen_f - a function f(row,col) which return the data value :

at that position, the default generator used yields values of the form "RxCy" based on position.

c_ndupe_l, r_ndupe_l - list of integers, determines the number :

of duplicates for each label at a given level of the corresponding index. The default :None:None:`None` value produces a multiplicity of 1 across all levels, i.e. a unique index. Will accept a partial list of length N < idx_nlevels, for just the first N levels. If ndupe doesn't divide nrows/ncol, the last label might have lower multiplicity.

dtype - passed to the DataFrame constructor as is, in case you wish to :

have more control in conjunction with a custom :None:None:`data_gen_f`

r_idx_type, c_idx_type - "i"/"f"/"s"/"u"/"dt"/"td". :

If idx_type is not None, :None:None:`idx_nlevels` must be 1. "i"/"f" creates an integer/float index, "s"/"u" creates a string/unicode index "dt" create a datetime index. "td" create a timedelta index.

if unspecified, string labels will be generated.

Create a DataFrame using supplied parameters.

Examples

# 5 row, 3 columns, default names on both, single index on both axis >> makeCustomDataframe(5,3)

# make the data a random int between 1 and 100 >> mkdf(5,3,data_gen_f=lambda r,c:randint(1,100))

# 2-level multiindex on rows with each label duplicated # twice on first level, default names on both axis, single # index on both axis >> a=makeCustomDataframe(5,3,r_idx_nlevels=2,r_ndupe_l=[2])

# DatetimeIndex on row, index with unicode labels on columns # no names on either axis >> a=makeCustomDataframe(5,3,c_idx_names=False,r_idx_names=False, r_idx_type="dt",c_idx_type="u")

# 4-level multindex on rows with names provided, 2-level multindex # on columns with default labels and default names. >> a=makeCustomDataframe(5,3,r_idx_nlevels=4, r_idx_names=["FEE","FIH","FOH","FUM"], c_idx_nlevels=2)

>> a=mkdf(5,3,r_idx_nlevels=2,c_idx_nlevels=4)

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/_testing/__init__.py#683
type: <class 'function'>
Commit: