Professional Documents
Culture Documents
strip()
columns_to_check = list(df.columns)
columns_to_check.remove('Date')
df = df.dropna(subset=columns_to_check, how='all')
df.loc[:, 'Date'] =
df['Date'].apply(convert_serial_to_date).fillna(method='ffill').apply(parse_date_on
ly)
df.loc[:, 'Date'] = df['Date'].apply(ethiopian_to_gregorian) # Convert
Ethiopian dates to Gregorian dates using ethiopian_date package
df = df.where(pd.notnull(df), None)
df_json = df.copy()
df_json.columns = df_json.columns.str.lower().str.replace(' ',
'_').str.replace(r'[()]+', '', regex=True)
df_json.rename(columns={"origin_country":"attack_origin"}, inplace=True)
###############################
df_json.rename(columns={"alert_name":"alert_message"}, inplace=True)
df_json['source_ips'] = df_json['source_ips'].apply(lambda x: x.split(','))
df_json['destination_ips'] = df_json['destination_ips'].apply(lambda x:
x.split(','))
df_json['attack_origin'] = df_json['attack_origin'].str.title()
df_json['attack_origin'] = df_json['attack_origin'].apply(replace_with_match)
df_json['attack_type'] = df_json['attack_type'].str.title()
###########################
json_data = df_json.to_json(orient='records')
if filename: