Mastering Data Time Series: Loading, Formatting, and Indexing a Pandas DataFrame with CSV File
import pandas as pd
# Load data from CSV file
df = pd.read_csv('foo.csv', index_col=['Date_Time'], parse_dates=[['Date','Time']])
# Convert date and time columns to datetime type
df.index = pd.to_datetime(df.index)
# Set the date and time column as the index
df.set_index("Date_Time", inplace=True)
Last modified on 2024-03-01