We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
data = """ date revenue name 0 2020-02-24 9 n_1 1 2020-05-12 8 n_2 2 2020-03-28 9 n_2 3 2020-01-14 2 n_0""" df = pd.read_csv(StringIO(data), sep = "\s+", engine = "python") df.date = pd.to_datetime(df.date) gb = df.groupby("name").resample("M", on="date") res1 = gb.sum()[['revenue']] # ==> # revenue # name date # n_0 2020-01-31 2 # n_1 2020-02-29 9 # n_2 2020-03-31 9 # 2020-04-30 0 # 2020-05-31 8 res2 = gb.aggregate({'revenue':'sum'}) # ==> # revenue # name date # n_0 2020-05-31 2 # n_1 2020-01-31 9 # n_2 2020-02-29 8 # 2020-03-31 9
As the code sample above shows, there are two issues:
agg(sum)
sum
The correct output is the one produced by sum.
pd.show_versions()
commit : None python : 3.7.5.final.0 python-bits : 64 OS : Darwin OS-release : 19.5.0 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8
pandas : 1.0.5 numpy : 1.17.4 pytz : 2019.3 dateutil : 2.8.0 pip : 19.3.1 setuptools : 41.6.0 Cython : None pytest : 5.4.3 hypothesis : 5.18.0 sphinx : None blosc : None feather : None xlsxwriter : 1.2.9 lxml.etree : 4.5.0 html5lib : 1.0.1 pymysql : None psycopg2 : 2.8.4 (dt dec pq3 ext lo64) jinja2 : 2.10.3 IPython : 7.10.1 pandas_datareader: 0.8.1 bs4 : 4.9.0 bottleneck : None fastparquet : None gcsfs : None lxml.etree : 4.5.0 matplotlib : 3.2.1 numexpr : None odfpy : None openpyxl : 3.0.3 pandas_gbq : None pyarrow : None pytables : None pytest : 5.4.3 pyxlsb : None s3fs : None scipy : 1.4.1 sqlalchemy : 1.3.16 tables : None tabulate : None xarray : 0.15.1 xlrd : 1.2.0 xlwt : None xlsxwriter : 1.2.9 numba : None
The text was updated successfully, but these errors were encountered:
Thanks @roy2006 for the excellent bug report!
Sorry, something went wrong.
Thanks @roy2006 this looks like a duplicate of #33548 so closing. lmk if i'm overlooking something.
No branches or pull requests
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
As the code sample above shows, there are two issues:
agg(sum)
produces different results from justsum
.agg(sum)
are plain wrong. The name "n_2" has no data in Feb, and yet - the aggregation shows that it does.Expected Output
The correct output is the one produced by
sum
.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.5.final.0
python-bits : 64
OS : Darwin
OS-release : 19.5.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.5
numpy : 1.17.4
pytz : 2019.3
dateutil : 2.8.0
pip : 19.3.1
setuptools : 41.6.0
Cython : None
pytest : 5.4.3
hypothesis : 5.18.0
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.2.9
lxml.etree : 4.5.0
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : 2.10.3
IPython : 7.10.1
pandas_datareader: 0.8.1
bs4 : 4.9.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.2.1
numexpr : None
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.4.3
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.16
tables : None
tabulate : None
xarray : 0.15.1
xlrd : 1.2.0
xlwt : None
xlsxwriter : 1.2.9
numba : None
The text was updated successfully, but these errors were encountered: