Skip to content

pandas FutureWarning when casting type in DatetimeIndex #1261

Closed
@hashstat

Description

@hashstat

A new FutureWarning warning is being issued from pandas from pvlib.solarposition.spa_python().

Steps to reproduce

>>> import pandas as pd
>>> import pvlib
>>> ti = pd.DatetimeIndex([pd.to_datetime('today')])
>>> pvlib.solarposition.spa_python(ti, 46.0, 119.0)

Observed behavior

.../lib/python3.9/site-packages/pvlib/solarposition.py:368: FutureWarning: casting datetime64[ns] values to int64 with .astype(...) is deprecated and will raise in a future version. Use .view(...) instead.
  unixtime = np.array(time.astype(np.int64)/10**9)
                            apparent_zenith  ...  equation_of_time
2021-07-15 09:58:51.008140        72.817018  ...         -6.010526
[1 rows x 6 columns]

Expected behavior

                            apparent_zenith  ...  equation_of_time
2021-07-15 09:58:51.008140        72.817018  ...         -6.010526
[1 rows x 6 columns]

Environment
pvlib version: 0.8.1
pandas version: 1.3.0
Python version: 3.9.6
OS: Arch Linux (up-to-date)

Additional information
We are not using pvlib directly; it is being pulled in by pvfactors. This issue started occurring when pandas was updated to 1.3.0.

May also be reproduced using pytest pvlib/tests/test_solarposition.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions