Skip to content

BUG: resample dropping column #53110

Open
@hyonschu

Description

@hyonschu

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

df = pd.read_csv('data.csv')

df.resample('M', on='Date In').count()

Issue Description

df.resample('M', on='Date In').count()

In prior versions, this used to output a dataframe where it kept column "Date In" and the count of Date In for all months relative to Date In.

In 2.0.1, it returns the same dataframe but without the count of "Date In," which is now the index of the dataframe.

If I want to use this function to understand how many came IN and OUT in the same month, this function no longer tells me that.

Expected Behavior

It should also keep the 'on=' column in the resulting DataFrame

Installed Versions

INSTALLED VERSIONS ------------------ commit : 37ea63d python : 3.9.4.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19041 machine : AMD64 processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : English_United States.1252

pandas : 2.0.1
numpy : 1.24.3
pytz : 2021.3
dateutil : 2.8.2
setuptools : 49.2.1
pip : 23.1.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.13.1
pandas_datareader: None
bs4 : 4.10.0
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.0
snappy : None
sqlalchemy : 2.0.12
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : 2.0.1
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugRegressionFunctionality that used to work in a prior pandas versionResampleresample method

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions