def get_kde_date_attribute_json(log, attribute=DEFAULT_TIMESTAMP_KEY, parameters=None): """ Gets the KDE estimation for the distribution of a date attribute values (expressed as JSON) Parameters ------------- log Event stream object (if log, is converted) attribute Date attribute to analyse parameters Possible parameters of the algorithm, including: graph_points -> number of points to include in the graph Returns -------------- x X-axis values to represent y Y-axis values to represent """ if type(log) is EventLog: event_log = log_conv_fact.apply(log, variant=log_conv_fact.TO_EVENT_STREAM) else: event_log = log values = [event[attribute].replace(tzinfo=None) for event in event_log if attribute in event] return attributes_common.get_kde_date_attribute_json(values, parameters=parameters)
def get_kde_date_attribute_json(df, attribute=DEFAULT_TIMESTAMP_KEY, parameters=None): """ Gets the KDE estimation for the distribution of a date attribute values (expressed as JSON) Parameters -------------- df Pandas dataframe attribute Date attribute to analyse parameters Possible parameters of the algorithm, including: graph_points -> number of points to include in the graph Returns -------------- json JSON representing the graph points """ values = list(df.dropna(subset=[attribute])[attribute]) return attributes_common.get_kde_date_attribute_json(values, parameters=parameters)
def get_kde_date_attribute_json(df, attribute=DEFAULT_TIMESTAMP_KEY, parameters=None): """ Gets the KDE estimation for the distribution of a date attribute values (expressed as JSON) """ values = df.select(attribute).rdd.map(lambda row: row[0]).collect() return attributes_common.get_kde_date_attribute_json(values, parameters=parameters)