-
-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
BUG: DatetimeIndex.is_year_start
returns incorrect array if .freq == 'MS'
#49606
Comments
I can take this one |
I was investigating this issue, as I understood there is something strange in the function get_start_end_field. [strange] [looks ok] [looks ok] Needs help to investigate:
I appreciate any help that guides me to figure out more about this issue :) Update: I found that in arrays/datetimes.py we are setting the month_kw to 12. I believe that here is the issue. with QS (works why?)In the scenario that we have a QS the freq object is with MS (does not work)The freq object is But why its work with freq = None?Because the function I will check the tests and certify that this is the right solution. if freq:
kwds = freq.kwds
- month_kw = kwds.get("startingMonth", kwds.get("month", 12))
+ month_kw = kwds.get("startingMonth", kwds.get("month", 1)) @alexanderwertman3, are you working on it? @jbrockmendel, @jorisvandenbossche May I open a PR with this solution?
|
I am going to start investigating the issue this week. It does seem odd that month_kw is set to 12 in get_start_end_field when freq == 'MS' |
@lohmanndouglas: I am still looking into as to why this might be the case. Clearly, there is a reason for defaulting month_kw to 12 because the change you made is causing tests to fail. |
which tests? |
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
Issue Description
The
.freq
property of theDatetimeIndex
influences the result of the.is_year_start
property. If it is set to MonthStart, the december timestamp is incorrectly recognised as the start of the year..is_quarter_start
has a similar issue.The issue does not arise for
.freq == 'QS'
.Expected Behavior
Even if
i.freq == 'MS'
, the result ofi.is_year_start
should start withTrue
, not end withTrue
.Installed Versions
INSTALLED VERSIONS
commit : 91111fd
python : 3.9.13.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 165 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252
pandas : 1.5.1
numpy : 1.23.4
pytz : 2022.6
dateutil : 2.8.2
setuptools : 63.4.1
pip : 22.2.2
Cython : None
pytest : 7.1.3
hypothesis : None
sphinx : 5.3.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.5.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.2
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: