Spaces:
Runtime error
Runtime error
Download pm4py/examples/dataframe_prefix_and_fea_extraction.py from linpershey/process_mining: direct link, hf CLI and curl.
- Browser
- Download file 857 Bytes
-
https://huggingface.co/spaces/linpershey/process_mining/resolve/main/pm4py/examples/dataframe_prefix_and_fea_extraction.py
- Command line
-
hf download hf://spaces/linpershey/process_mining/pm4py/examples/dataframe_prefix_and_fea_extraction.py
-
curl -L -o dataframe_prefix_and_fea_extraction.py https://huggingface.co/spaces/linpershey/process_mining/resolve/main/pm4py/examples/dataframe_prefix_and_fea_extraction.py
857 Bytes
| from pm4py.objects.log.util import dataframe_utils | |
| from pm4py.util import pandas_utils, constants | |
| def execute_script(): | |
| # loads a dataframe. setup dates | |
| df = pandas_utils.read_csv("../tests/input_data/receipt.csv") | |
| df = dataframe_utils.convert_timestamp_columns_in_df(df, timest_format=constants.DEFAULT_TIMESTAMP_PARSE_FORMAT) | |
| print(df) | |
| # insert the case index in the dataframe | |
| df = pandas_utils.insert_ev_in_tr_index(df, case_id="case:concept:name", column_name="@@index_in_trace") | |
| # filter all the prefixes of length 5 from the dataframe | |
| df = df[df["@@index_in_trace"] <= 5] | |
| print(df) | |
| # performs the automatic feature extraction | |
| fea_df = dataframe_utils.automatic_feature_extraction_df(df) | |
| print("\nfea_df =") | |
| print(fea_df) | |
| print(fea_df.columns) | |
| if __name__ == "__main__": | |
| execute_script() | |