Plug4
Plug4

Reputation: 3938

Python: pd.read_csv - import all numbers after the decimal

In my csv file that I wish to import, I have a column Timestamp with nanoseconds precision: 34200.154875632 and so on.

When I write:

dfr = pd.read_csv(files,index_col=None,usecols=['Timestamp','Price'], header=0,dtype=np.float)  
df=DataFrame(dfr)

I do not get a DataFrame with a column of Timestamp with all nice decimals...only six. I tried to play around with the input dtype=np.float but no result. What's the missing argument in pd.read_csv to have all nine decimals?

Upvotes: 2

Views: 2712

Answers (2)

reptilicus
reptilicus

Reputation: 10397

This is probably due to the print precision of pandas. Look into pandas.set_printoptions.

It looks like pandas.set_printoptions is now deprecated in v0.13, it seems to use pandas.set_option

Upvotes: 1

Plug4
Plug4

Reputation: 3938

I found the correct code

import Pandas
pd.options.display.float_format = '{:20,.2f}'.format

Upvotes: 2

Related Questions