# Data Preprocessing Method and API for Mining Processes from Cloud-Based Application Event Logs
## 5 CPA-PM Application Programming Interface (API)  
This section presents the API functions, mainly described in terms of addition, removal, or modification of rows, columns, and traces. As the purpose here is to simplify and shorten event logs, the API offers mainly removal and modification functions. Please note that in the following, an event log table with a heading row is also called a dataframe. Most of the functions (except _write_CSV) return a new dataframe. * **readCSV** (String file): reads the CSV file into a dataframe that it creates. * **writeCSV** (table DataSet, String file): writes the dataframe to a file. * **cleanHeaders** (table DataSet): cleans the dataset's headers of the columns from spaces (replaced with _) and other special characters (removed). This function only keeps lower case letters, numbers, and underscores (_), and it ensures that the resulting names are unique. * **selectColumns** (table DataSet, string columnName,...): selects/keeps the list of columns needed for analysis from the dataset. Only the list of selected columns (attributes) are included in the dataset. * **deleteColumns** (table DataSet, string columnName,...): drops the listed columns from the dataset. * **filter** (table DataSet, condition Conditions): keeps records/rows based on the conditions specified. Only the rows where the condition is true are kept in the DataSet. Comparison and composite functions are supported with ==, \(>\), \(<\), \(>\)=, \(<\)=, &, \(\mid\), and \(\mid\). * **removeEventsLowFrequency** (table DataSet, String eventName, integer freq): removes the events from the dataset that have a frequency below the value _freq_ (count integer) when grouping by _eventName_. * **deleteTraceLengthLessThan** (table DataSet, String groupID, integer num): removes the traces where the number of events is less than a specified value. _groupID_ is the name of the variable to group traces by, and _num_ is the minimum number of events. * **deleteTruncatedTraceStart** (table DataSet, String groupID, String eventColumn, String value): removes the traces/traces that do not start with the required event value. _groupID_ is the name of the variable to group traces by, and _eventColumn_ is the name of the event column. _value_ is the value of the eventColumn that specifies the required start event name. * **deleteTruncatedTraceEnd** (table DataSet, String groupID, String eventColumn, String value): similar to the previous one, but removes the traces/cases that do not _end_ with the required event. * **deleteTraceWithTimeLess** (table DataSet, String groupID, String timestampColumn, integer t): removes the traces/cases that ran for a total duration less than \(t\). _timestampColumn_ is the name of the timestamp column, and \(t\) is the value of the minimum total duration for each trace/case, in seconds. * **concatenateColumns** (table DataSet, String newColumn, String col1, String col2,...): concatenates two or more columns (\(col1\), \(col2\),...) in a dataframe into a _newColumn_ that is added to the dataframe. * **arrangeRows** (table DataSet, String columnName,...): sorts the rows by _columnName_, in increasing order. _columnName_ is a list of unquoted names. * **eventsRepeated** (table DataSet, String groupIDCol, String eventCol, String newCol): creates a new column _newCol_ that indicates whether the event has been repeated or not. The event is represented by the _eventCol_ parameter. The new column will only include values 0 (when not repeated) or 1 (when repeated). * **deleteAllEvents** (table DataSet, String event, String eventName): deletes all records/rows with an _eventName_ value in the _event_ column. * **keepFirstEvent** (table DataSet, groupID, String eventAttribute, String eventName): keeps the first occurrence of an event (i.e., the first occurrence of several repeated events). _groupID_ represents the column for grouping the records, _eventAttribute_ the event attribute column, and _eventName_ the event name whose first occurrence in each group we want to keep.