Skip to content

ValueError Exception during reset_index of timezone-aware data #7875

Closed
@vac

Description

@vac
import pandas as pd
import numpy as np
from datetime import datetime
import pytz

print "This is working:"
data = {23:np.nan, 24:-1949, 25:-1848, 26: np.nan}
date_without_timezone = datetime.now()
df = pd.DataFrame(data, index=[date_without_timezone,])
print df
print
print df.index
print
print df.stack()
print
print df.stack().reset_index() #Good (expected) result

print
print "--------------------"
print

print "This is NOT working:"
date_with_timezone = datetime.now(pytz.utc)
df_with_timezone = pd.DataFrame(data, index=[date_with_timezone,])
print df_with_timezone
print
print df_with_timezone.index
print
print df_with_timezone.stack()
print
print df_with_timezone.stack().reset_index() # EXCEPTION: ValueError: Length of values does not match length of index

INSTALLED VERSIONS

commit: None
python: 2.7.5.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: PL

pandas: 0.14.1
nose: None
Cython: None
numpy: 1.8.1
scipy: None
statsmodels: None
IPython: 2.1.0
sphinx: None
patsy: None
scikits.timeseries: None
dateutil: 2.1
pytz: 2014.2
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.3.1
openpyxl: 2.0.3
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.4
pymysql: None
psycopg2: 2.5.3 (dt dec pq3 ext)

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