Panda: read csv datetime
Revision as of 08:40, 7 August 2019 by Onnowpurbo (talk | contribs)
Cara 1
import pandas x = pandas.read_csv('/home/onno/TensorFlow/TEMP-train.csv', parse_dates=True, index_col='DateTime', names=['DateTime', 'X'], header=None, sep=',') x
Cara 2
import numpy as np import matplotlib.pyplot as plt import pandas as pd infile = '/home/onno/TensorFlow/TEMP-train.csv' mydateparser = lambda x: pd.datetime.strptime(x, "%Y-%m-%d %H:%M:%S") df = pd.read_csv(infile, sep=',', names=['datetime', 'value'], parse_dates=['datetime'], date_parser=mydateparser)