A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/7630 below:

tz lost on combine first/fillna · Issue #7630 · pandas-dev/pandas · GitHub

http://stackoverflow.com/questions/24502838/pandas-tzinfo-lost-by-combine-first

In [10]: df1 = pd.DataFrame(columns=['UTCdatetime','abc'],
   ....:                   data=pd.to_datetime('20100101 01:01').tz_localize('UTC'),
   ....:                   index=pd.date_range('20140627', periods=1))

In [11]: print(df1)
                          UTCdatetime                        abc
2014-06-27  2010-01-01 01:01:00+00:00  2010-01-01 01:01:00+00:00

In [12]: df2 = pd.DataFrame(columns=['UTCdatetime','xyz'],
   ....:                   data=pd.to_datetime('20121212 12:12').tz_localize('UTC'),
   ....:                   index=pd.date_range('20140628', periods=1))

In [13]: 

In [13]: df1
Out[13]: 
                          UTCdatetime                        abc
2014-06-27  2010-01-01 01:01:00+00:00  2010-01-01 01:01:00+00:00

In [14]: df2
Out[14]: 
                          UTCdatetime                        xyz
2014-06-28  2012-12-12 12:12:00+00:00  2012-12-12 12:12:00+00:00

In [15]: df1.dtypes
Out[15]: 
UTCdatetime    object
abc            object
dtype: object

In [16]: df2.dtypes
Out[16]: 
UTCdatetime    object
xyz            object
dtype: object

In [17]: df2[['UTCdatetime']].combine_first(df1)
Out[17]: 
                   UTCdatetime                        abc
2014-06-27 2010-01-01 01:01:00  2010-01-01 01:01:00+00:00
2014-06-28 2012-12-12 12:12:00                        NaN

In [18]: df2[['UTCdatetime']].combine_first(df1).dtypes
Out[18]: 
UTCdatetime    datetime64[ns]
abc                    object
dtype: object

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4