-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
shift() broken for datetime64 when used with fill_value #31971
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
Comments
@BayerSe thanks for the report! I vaguely seem to remember some changes related to |
Caused by #28852: I suppose the change was done on purpose, but it also didn't explicitly test that change or have a mention in the whatsnew |
@jbrockmendel can you comment on whether this was intentional? I find several PRs that are related to this maybe_promote, but not one (or an issue) that discusses the reasoning or the implications. |
Looks like in Block.shift it is calling We either need to patch Series.shift to dispatch to self._values when that is an EA, or patch DatetimeBlock to use array_values (probably also TimedeltaBlock, and that only handles the 1D cases) @BayerSe until we get this patched i think you're best off passing |
@jbrockmendel Did as you suggested, thanks for the hint. |
Should this be marked as a regression? |
I think so. For now, my preference would be to just catch this case specifically, I think as explicitly as if is_datetime64ns_dtype(self.values.dtype) and isinstance(periods, int):
periods = pd.Timestamp(periods) I also think that this should warn and eventually in the future (1.1), instructing users to fill with a Timestamp. |
Longer-term the solution is to patch DatetimeBlock.shift to dispatch to DTA.shift. ATM DTA.shift accepts ints, so I think that would fix the regression for 1.0.2. That said, it shouldnt accept ints, so we'll need to deprecate that behavior on the DTA, which will in turn effectively deprecate it for Series too. |
That sounds good to me. Did you say you're able to work on a patch to fix this regression for 1.0.2 to (temporarily) allow ints again? |
yah, im running the tests locally now, with luck will push in a few minutes |
Code Sample, a copy-pastable example if possible
Problem description
Above code snippet works on version 0.25.3 but breaks with 1.0.1.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-72-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.2.0.post20200210
Cython : None
pytest : 5.3.2
hypothesis : None
sphinx : 2.3.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.11.1
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.15.1
pytables : None
pytest : 5.3.2
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None
The text was updated successfully, but these errors were encountered: