niimpy.exploration.eda.punchcard module

Created on Thu Nov 18 16:14:47 2021

@author: arsii

niimpy.exploration.eda.punchcard.combine_dataframe_(df, user_list, columns, res, date_index, agg_func='mean')[source]

resample values from multiple users into new dataframe

Parameters:
dfPandas Dataframe

Dataframe containing the data

user_listlist

List containing user names/id’s (str)

columnslist

List of column names (str) to be plotted

resstr

Resample parameter e.g., ‘D’ for resampling by day

date_indexpd.date_range

Date range used as an index

agg_funcnumpy function

Aggregation function used with resample. The default is “mean”

Returns:
df_combpd.DataFrame

Resampled and combined dataframe

niimpy.exploration.eda.punchcard.get_timerange_(df, resample)[source]

get first and last timepoint from the dataframe, and return a resampled datetimeindex.

Parameters:
dfPandas Dataframe

Dataframe containing the data

ressamplestr

Resample parameter e.g., ‘D’ for resampling by day

Returns:
date_indexpd.DatatimeIndex

Resampled DatetimeIndex

niimpy.exploration.eda.punchcard.punchcard_(df, title, n_xticks, xtitle, ytitle)[source]

create a punchcard plot

Parameters:
dfPandas Dataframe

Dataframe containing the data

titlestr

Plot title.

n_xticksint or None

Number of xaxis ticks. If None, scaled automatically.

xtitlestr

Plot xaxis title

ytitlestr

Plot yaxis title

Returns:
figplotly.graph_objs._figure.Figure

Punchcard plot

niimpy.exploration.eda.punchcard.punchcard_plot(df, user_list=None, columns=None, title='Punchcard Plot', resample='D', normalize=False, agg_func='mean', timerange=False)[source]

Punchcard plot for given users and column with optional resampling

Parameters:
dfPandas Dataframe

Dataframe containing the data

user_listlist, optional

List containing user id’s as string. The default is None.

columnslist, optional

List containing columns as strings. The default is None.

titlestr, optional

Plot title. The default is “Punchcard Plot”.

resamplestr, optional

Indicator for resampling frequency. The default is ‘D’ (day).

agg_funcnumpy function

Aggregation function used with resample. The default is np.mean

normalizeboolean, optional

If true, data is normalized using min-max-scaling. The default is False.

timerangeboolean or tuple, optional

If false, timerange is not filtered. If tuple containing timestamps, timerange is filtered. The default is False.

Returns:
figplotly.graph_objs._figure.Figure

Punchcard plot