Created
February 8, 2020 17:07
-
-
Save CharlyWargnier/7bde8b2b79ffcd59488df55f9ed6cbbc to your computer and use it in GitHub Desktop.
This file contains 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
# Split Date & Time | |
df[['Date_Time', 'header']] = df['header'].str.split("\] ", 1, | |
expand=True) | |
df['Date_Time'] = df['Date_Time'].str.replace(':.*', '') | |
# Convert the Date_Time column from string to datetime format | |
df['Date'] = pd.to_datetime(df['Date_Time'], errors='coerce', | |
infer_datetime_format=True) | |
# Remove Time column, for clarity's sake | |
df = df.drop(['Date_Time'], axis=1) | |
# Check that the Date column has been converted to a time series | |
df.info() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment