Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas read_csv dtype datetime

#You might try passing actual types instead of strings.
import pandas as pd
from datetime import datetime
headers = ['col1', 'col2', 'col3', 'col4'] 
dtypes = [datetime, datetime, str, float] 
pd.read_csv(file, sep='	', header=None, names=headers, dtype=dtypes)

#But it's going to be really hard to diagnose this without any of your 
#data to tinker with. And really, you probably want pandas to parse 
#the the dates into TimeStamps, so that might be:
pd.read_csv(file, sep='	', header=None, names=headers, parse_dates=True)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #dtype #datetime
ADD COMMENT
Topic
Name
9+6 =