Bug: Series[category].replace casts incorrectly · Issue #26988 · pandas-dev/pandas (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
dti = pd.date_range('2016-01-01', periods=3, tz='US/Pacific')
ser = pd.Series(dti)
cat = ser.astype('category')
>>> cat
0 2016-01-01 00:00:00-08:00
1 2016-01-02 00:00:00-08:00
2 2016-01-03 00:00:00-08:00
dtype: category
Categories (3, datetime64[ns, US/Pacific]): [2016-01-01 00:00:00-08:00, 2016-01-02 00:00:00-08:00,
2016-01-03 00:00:00-08:00]
>>> cat.replace(cat[1], 'foo')
0 1451635200000000000
1 1451721600000000000
2 1451808000000000000
dtype: int64