11import logging
22
3- from pm4py .util import constants , xes_constants , pandas_utils
3+ import deprecation
4+
5+ from pm4py import VERSION
46
57INDEX_COLUMN = "@@index"
68
@@ -24,6 +26,9 @@ def read_xes(file_path):
2426 return log
2527
2628
29+ @deprecation .deprecated (deprecated_in = "2.0.1.3" , removed_in = "3.0" ,
30+ current_version = VERSION ,
31+ details = "Use pandas to import CSV files" )
2732def read_csv (file_path , sep = "," , quotechar = None , encoding = 'utf-8' , nrows = 10000000 , timest_format = None ):
2833 """
2934 Reads an event log in the CSV format (Pandas adapter)
@@ -59,52 +64,13 @@ def read_csv(file_path, sep=",", quotechar=None, encoding='utf-8', nrows=1000000
5964 logging .error (
6065 "Less than three columns were imported from the CSV file. Please check the specification of the separation and the quote character!" )
6166 else :
62- #logging.warning(
67+ # logging.warning(
6368 # "Please specify the format of the dataframe: df = pm4py.format_dataframe(df, case_id='<name of the case ID column>', activity_key='<name of the activity column>', timestamp_key='<name of the timestamp column>')")
6469 pass
6570
6671 return df
6772
6873
69- def format_dataframe (df , case_id = constants .CASE_CONCEPT_NAME , activity_key = xes_constants .DEFAULT_NAME_KEY ,
70- timestamp_key = xes_constants .DEFAULT_TIMESTAMP_KEY ):
71- """
72- Give the appropriate format on the dataframe, for process mining purposes
73-
74- Parameters
75- --------------
76- df
77- Dataframe
78- case_id
79- Case identifier column
80- activity_key
81- Activity column
82- timestamp_key
83- Timestamp column
84-
85- Returns
86- --------------
87- df
88- Dataframe
89- """
90- if case_id not in df .columns :
91- raise Exception (case_id + " column (case ID) is not in the dataframe!" )
92- if activity_key not in df .columns :
93- raise Exception (activity_key + " column (activity) is not in the dataframe!" )
94- if timestamp_key not in df .columns :
95- raise Exception (timestamp_key + " column (timestamp) is not in the dataframe!" )
96- df = df .rename (columns = {case_id : constants .CASE_CONCEPT_NAME , activity_key : xes_constants .DEFAULT_NAME_KEY ,
97- timestamp_key : xes_constants .DEFAULT_TIMESTAMP_KEY })
98- df [constants .CASE_CONCEPT_NAME ] = df [constants .CASE_CONCEPT_NAME ].astype (str )
99- # set an index column
100- df = pandas_utils .insert_index (df , INDEX_COLUMN )
101- # sorts the dataframe
102- df = df .sort_values ([constants .CASE_CONCEPT_NAME , xes_constants .DEFAULT_TIMESTAMP_KEY , INDEX_COLUMN ])
103- # logging.warning(
104- # "please convert the dataframe for advanced process mining applications. log = pm4py.convert_to_event_log(df)")
105- return df
106-
107-
10874def convert_to_event_log (obj ):
10975 """
11076 Converts a log object to an event log
0 commit comments