Code Sample, a copy-pastable example if possible
# create grouped Pandas DataFrame
gpdf = pdf.groupby('bins', as_index=False)
# create difference table statistics from gpdf in a new DataFrame
diffs_without_sums = stat_dataframe(gpdf)
# calculate sums row
row = get_sums(diffs_without_sums)[diffs_without_sums.columns]
row['mean'] = 0
if row['count'] > 0:
row['mean'] = row['tot_change'] / row['count']
row['perc_cut'] = sums_perc_cut
row['perc_inc'] = sums_perc_inc
row['share_of_change'] = 1.0 # avoid rounding error
diffs = diffs_without_sums.append(row)
# append top-decile-detail rows
if groupby == 'weighted_deciles':
pdf = gpdf.get_group(10) # top decile as its own DataFrame
pdf = add_quantile_bins(copy.deepcopy(pdf), income_measure, 10)
# TODO: following statement generates this IGNORED error:
# ValueError: Buffer dtype mismatch,
# expected 'Python object' but got 'long'
# Exception ValueError: "Buffer dtype mismatch,
# expected 'Python object' but got 'long'"
# in 'pandas._libs.lib.is_bool_array' ignored
# ^^^^^^^
# It is hoped that Pandas PR#17841, which is scheduled for <================
# inclusion in Pandas version 0.22.0 (Jan 2018), will fix this. <===========
pdf['bins'].replace(to_replace=[1, 2, 3, 4, 5],
value=[0, 0, 0, 0, 0], inplace=True)
pdf['bins'].replace(to_replace=[6, 7, 8, 9],
value=[1, 1, 1, 1], inplace=True)
pdf['bins'].replace(to_replace=[10], value=[2], inplace=True)
gpdf = pdf.groupby('bins', as_index=False)
sdf = stat_dataframe(gpdf)
diffs = diffs.append(sdf, ignore_index=True)
return diffs
Problem description
Get ignored error message described in code fragment above, which is causing Tax-Calculator users confusion (see, for example, Tax-Calculator issue 1799). If there is an error, why does Pandas ignore it? If there is not an error, why does Pandas print an error message and then ignore it? Based on the conversation in #18252, we had expected this error message to go away after we upgraded to 0.22.0, but that doesn't seem to be the case.
Expected Output
I would expect a non-ignored error message that stops program execution if I am using pandas incorrectly.
Or I would expect no error message if I am using pandas correctly.
But I get neither.
Output of pd.show_versions()
iMac2:tax-calculator mrh$ python
Python 2.7.14 |Anaconda custom (64-bit)| (default, Oct 5 2017, 02:28:52)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
import pandas as pd
>>>
pd.show_versions()
INSTALLED VERSIONS
commit: None python: 2.7.14.final.0 python-bits: 64 OS: Darwin OS-release: 16.7.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: None.None
pandas: 0.22.0
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.5.0.post20170921
Cython: 0.26.1
numpy: 1.13.3
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 5.4.1
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.1.0
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.2.0
xlsxwriter: 1.0.2
lxml: 4.1.0
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
>>>
Comment From: jreback
this is pushed in 0.23.0. (was called 0.22.0 at some point, but we released a single change in 0.22.0).
Comment From: martinholmer
@jreback, Thanks for the quick update on pandas release plans.