pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example if possible

1. replace bool with int (#12780)

NG, should be int Series

pd.Series([True]).replace({True: 3})
#0    True
# dtype: bool
2. replace datetime/timedelta with int (#12780)

NG, should be int Series

pd.Series([pd.Timestamp('2011-01-01')]).replace({pd.Timestamp('2011-01-01'): 3})
#0   1970-01-01 00:00:00.000000003
# dtype: datetime64[ns]

pd.Series([pd.Timedelta('1 days')]).replace({pd.Timedelta('1 days'): 3})
#0   00:00:00.000000
# dtype: timedelta64[ns]
3. replace datetime/timedelta with object (#12780)

NG, coerced to internal repr unexpectedly.

rep = {pd.Timestamp('2011-01-01'): 'a', pd.Timestamp('2011-01-02'): 'b'}
pd.Series([pd.Timestamp('2011-01-01'), pd.Timestamp('2011-01-02')]).replace(rep)
#0    1293840000000000000
#1                      b
# dtype: object
4. replace with datetimetz (#12780)

NG, coerced to GMT

pd.Series(['a']).replace({'a': pd.Timestamp('2011-01-01', tz='US/Eastern')})
#0   2011-01-01 05:00:00
# dtype: datetime64[ns]
5. replacement of string (open, see #15743)
In [37]: pd.Series([1,2,3]).replace('1', np.nan)
Out[37]: 
0    NaN
1    2.0
2    3.0
dtype: float64

output of pd.show_versions()

Latest master.