Pandas version checks

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

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

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

Reproducible Example

import datetime
import pandas as pd
import pytz

rng = pd.date_range(start="1/1/2000", periods=1, tz="Etc/GMT+8")
ts = pd.DataFrame(list(range(len(rng))), index=rng)
midnight_gmt_7 = datetime.time(tzinfo=pytz.timezone("Etc/GMT+7"))
print(ts.between_time(midnight_gmt_7, midnight_gmt_7, inclusive='both'))

Issue Description

between_time ignores the timezone info of start_time and end_time. In the example above, it counts midnight in GMT + 7 as equal to midnight in GMT + 8. Note also that ts.at_time(midnight_gmt_7) correctly gives an empty list .

Expected Behavior

between_time should account for timezone, as at_time does here: https://github.com/pandas-dev/pandas/blob/a063af0e6d443c4b5826eed2102a6d3c988da9a0/pandas/core/indexes/datetimes.py#L723-L726

Instead, betwen_time just converts to micros without looking at time zone: https://github.com/pandas-dev/pandas/blob/a063af0e6d443c4b5826eed2102a6d3c988da9a0/pandas/core/indexes/datetimes.py#L756-L757

Installed Versions

INSTALLED VERSIONS

commit : 7cb7592523380133f552e258f272a5694e37957a python : 3.10.4.final.0 python-bits : 64 OS : Darwin OS-release : 21.5.0 Version : Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 2.0.0.dev0+1147.g7cb7592523 numpy : 1.23.3 pytz : 2022.2.1 dateutil : 2.8.2 setuptools : 63.4.1 pip : 22.1.2 Cython : 0.29.32 pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : 8.5.0 pandas_datareader: None bs4 : None bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None 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 zstandard : None tzdata : None qtpy : None pyqt5 : None

0
© 2022 pullanswer.com - All rights reserved.