python - Specify DataType using read_table() in Pandas -
i loading text file pandas, , have field contains year. want make sure field string when pulled dataframe.
i can seem work if specify exact length of string using code below: df = pd.read_table('myfile.tsv', dtype={'year':'s4'})
is there way without specifying length? need perform action on different columns vary in length.
i believe enabled in 0.12
you can pass str
,np.str_
,object
in place of s4
convert object
dtype in event
or after read in
df['year'].astype(object)
Comments
Post a Comment