Skip to content Skip to sidebar Skip to footer

Can I Export Pandas Dataframe To Excel Stripping Tzinfo?

I have a timezone aware TimeSeries in pandas 0.10.1. I want to export to Excel, but the timezone prevents the date from being recognized as a date in Excel. In [40]: resultado Out[

Solution 1:

You can simply create a copy without timezone.

import pandas as pa

time = pa.Timestamp('2013-04-16 10:08', tz='Europe/Berlin')
time_wo_tz = pa.datetime(year=time.year, month=time.month, day=time.day, 
                         hour=time.hour, minute=time.minute, second=time.second,
                         microsecond=time.microsecond)

When you want to convert the whole index of the timeseries, use a list comprehension.

ts.index = [pa.datetime(year=x.year, month=x.month, day=x.day, 
                        hour=x.hour, minute=x.minute, second=x.second, 
                        microsecond=x.microsecond) 
            for x in ts.index]

Post a Comment for "Can I Export Pandas Dataframe To Excel Stripping Tzinfo?"