Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Length of df = {:,}".format(len(gdf))) | |
%time cleaned_df = extract_columns_without_regex(gdf) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_columns_small_regex_pd(df): | |
p1 = """\\[haproxy@([0-9.]*)\\]\\s\\S*([A-Z][\\S\\s]*) ([\\S]*)\\[([0-9]*)\\]:([\\S\\s]*)""" | |
df1 = df['logline'].str.extract(p1) | |
temp_cols = cols[:4] | |
temp_cols.append("suffix") | |
df1.columns = temp_cols | |
p2 = """\\s([0-9.]*):([0-9]*)\\s\\[([\\S]*)\\]([\\S\\s]*)""" | |
extract_p2_df = df1['suffix'].str.extract(p2) | |
df2 = pd.concat([df1,extract_p2_df ], axis=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_columns_custom_pd(df): | |
### added expland=True for split | |
### changed drop_column to drop | |
clean_df = df['logline'].str.split(' ',expand=True) | |
# log_ip column | |
clean_df['log_ip'] = clean_df[0].str.lstrip('[haproxy@').str.rstrip(']') | |
clean_df.drop(columns = [0],inplace=True) |