Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow read_sql to avoid conversion to float #17560

Closed
konstantinmiller opened this issue Sep 17, 2017 · 1 comment
Closed

allow read_sql to avoid conversion to float #17560

konstantinmiller opened this issue Sep 17, 2017 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request IO SQL to_sql, read_sql, read_sql_query

Comments

@konstantinmiller
Copy link

Code Sample

import ibm_db_dbi
import ibm_db
import pandas as pd

conn_str = "DATABASE=<...>;HOSTNAME=<...>;PORT=<...>;PROTOCOL=TCPIP;UID=<...>;PWD=<...>;"
conn = ibm_db.connect(conn_str, "", "")
conni = ibm_db_dbi.Connection(conn)
df = pd.read_sql('SELECT <some rows> from <some table>, conni, coerce_float=False)

Problem description

If the SQL table contains integer columns with NULL values, the returned df has them converted to floats. I understand that it is currently not possible with pandas to have integer columns with NULL values. However, I want to be able to tell pandas NOT to convert the values to floats, in order not to loose precision. This is possible for other similar functions in pandas, such as read_csv, which has the argument dtype. Why not for read_sql??

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.0.final.0
python-bits: 64
OS: Darwin
OS-release: 16.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.2
pytest: 3.0.5
pip: 9.0.1
setuptools: 36.0.1
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.19.1
xarray: None
IPython: 6.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.1
tables: 3.3.0
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.8.0
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.4
s3fs: None
pandas_gbq: None
pandas_datareader: None

@TomAugspurger
Copy link
Contributor

There's an open issue for this in #13049

@jorisvandenbossche jorisvandenbossche added Duplicate Report Duplicate issue or pull request IO SQL to_sql, read_sql, read_sql_query labels Sep 18, 2017
@jorisvandenbossche jorisvandenbossche added this to the No action milestone Sep 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

No branches or pull requests

3 participants