Skip to content

BUG: Inconsistent behavior of Series.values with Series.array or Series.to_numpy() #55128

Open
@anmyachev

Description

@anmyachev

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

series = pandas.Series([pandas.Timestamp("2016-01-01", tz="US/Eastern") for _ in range(3)])
print(series.values)
# ['2016-01-01T05:00:00.000000000' '2016-01-01T05:00:00.000000000'
#  '2016-01-01T05:00:00.000000000']

print(series.array)
# <DatetimeArray>
# ['2016-01-01 00:00:00-05:00', '2016-01-01 00:00:00-05:00',
#  '2016-01-01 00:00:00-05:00']
# Length: 3, dtype: datetime64[ns, US/Eastern]

print(series.to_numpy())
# [Timestamp('2016-01-01 00:00:00-0500', tz='US/Eastern')
#  Timestamp('2016-01-01 00:00:00-0500', tz='US/Eastern')
#  Timestamp('2016-01-01 00:00:00-0500', tz='US/Eastern')]

Issue Description

.values output does not match .array output neither .to_numpy() output

Expected Behavior

In this case, the expected behavior is when the output of .value matches the output of .array (my guess).

Installed Versions

INSTALLED VERSIONS
------------------
commit              : ba1cccd19da778f0c3a7d6a885685da16a072870
python              : 3.9.17.final.0
python-bits         : 64
OS                  : Windows
OS-release          : 10
Version             : 10.0.22621
machine             : AMD64
processor           : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder           : little
LC_ALL              : None
LANG                : en_US.UTF-8
LOCALE              : English_United States.1252

pandas              : 2.1.0
numpy               : 1.25.2
pytz                : 2023.3
dateutil            : 2.8.2
setuptools          : 68.0.0
pip                 : 23.2.1
Cython              : None
pytest              : 7.4.0
hypothesis          : None
sphinx              : 7.1.1
blosc               : None
feather             : None
xlsxwriter          : None
lxml.etree          : 4.9.3
html5lib            : None
pymysql             : None
psycopg2            : 2.9.6
jinja2              : 3.1.2
IPython             : 8.12.2
pandas_datareader   : None
bs4                 : 4.12.2
bottleneck          : None
dataframe-api-compat: None
fastparquet         : 2023.7.0
fsspec              : 2023.6.0
gcsfs               : None
matplotlib          : 3.7.2
numba               : None
numexpr             : 2.8.4
odfpy               : None
openpyxl            : 3.1.2
pandas_gbq          : 0.15.0
pyarrow             : 11.0.0
pyreadstat          : None
pyxlsb              : None
s3fs                : 2023.6.0
scipy               : 1.11.2
sqlalchemy          : 2.0.20
tables              : 3.8.0
tabulate            : None
xarray              : None
xlrd                : 2.0.1
zstandard           : None
tzdata              : 2023.3
qtpy                : 2.3.1
pyqt5               : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team memberTimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions