Created
February 21, 2017 15:06
-
-
Save cryptowen/0f94d6679d34d9d5ffaaba7690b42aef to your computer and use it in GitHub Desktop.
convert value to demical when read_csv in pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import pandas as pd | |
import io | |
import decimal as D | |
temp = u"""a,b,c,d | |
0.1,0.2,0.1,0.2""" | |
df = pd.read_csv( | |
io.StringIO(temp), converters={'c': D.Decimal, | |
'd': D.Decimal}) | |
for i, v in df.iterrows(): | |
print(type(v.a), type(v.b), type(v.c), type(v.d)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment