Skip to content

df.reset_index fails with tz-aware column (similar to #7533) #7819

Closed
@rockg

Description

@rockg

The below fails with "ValueError: Length of values does not match length of index". However, without the timezone it works fine. It's because of pandas/core/frame.py _maybe_casted_values index.tz is not None clause. Something similar was done in #7533 but the added examples don't test this case. cc @sinhrks

import pandas as pd
import numpy as np

dts     =   pd.date_range('1/1/2012', '1/31/2012', freq='D', tz='US/Eastern')
columns =   [1, 2, 3]
data    =   np.random.randn(31, 3)

frame   =   pd.DataFrame(data, columns=columns, index=dts)
frame   =   frame.stack()
frame.reset_index()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions