<p dir="auto">(pandas versions: 0.17.0, 0.18.0)</p>
<p dir="auto">It seems that <code class="notranslate">Series.replace</code> is orders of magnitude slower than <code class="notranslate">Series.map</code> when called with a dict, and consumes enormous amounts of RAM:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; np.random.seed(0)
&gt;&gt;&gt; s = pd.Series(np.random.randint(0, 10000, 1000000))
&gt;&gt;&gt; r = {np.random.randint(0, 10000): np.random.randint(10000) for _ in range(1000)}
&gt;&gt;&gt; assert (s.map(r).fillna(s) == s.replace(r)).all()
&gt;&gt;&gt; %timeit s.replace(r)
1 loop, best of 3: 1.63 s per loop
&gt;&gt;&gt; %timeit s.map(r).fillna(s)
10 loops, best of 3: 26.6 ms per loop"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">seed</span>(<span class="pl-c1">0</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randint</span>(<span class="pl-c1">0</span>, <span class="pl-c1">10000</span>, <span class="pl-c1">1000000</span>))
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">r</span> <span class="pl-c1">=</span> {<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randint</span>(<span class="pl-c1">0</span>, <span class="pl-c1">10000</span>): <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randint</span>(<span class="pl-c1">10000</span>) <span class="pl-k">for</span> <span class="pl-s1">_</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">1000</span>)}
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">assert</span> (<span class="pl-s1">s</span>.<span class="pl-en">map</span>(<span class="pl-s1">r</span>).<span class="pl-en">fillna</span>(<span class="pl-s1">s</span>) <span class="pl-c1">==</span> <span class="pl-s1">s</span>.<span class="pl-en">replace</span>(<span class="pl-s1">r</span>)).<span class="pl-en">all</span>()
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-c1">%</span><span class="pl-s1">timeit</span> <span class="pl-s1">s</span>.<span class="pl-en">replace</span>(<span class="pl-s1">r</span>)
<span class="pl-c1">1</span> <span class="pl-s1">loop</span>, <span class="pl-s1">best</span> <span class="pl-s1">of</span> <span class="pl-c1">3</span>: <span class="pl-c1">1.63</span> <span class="pl-s1">s</span> <span class="pl-s1">per</span> <span class="pl-s1">loop</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-c1">%</span><span class="pl-s1">timeit</span> <span class="pl-s1">s</span>.<span class="pl-en">map</span>(<span class="pl-s1">r</span>).<span class="pl-en">fillna</span>(<span class="pl-s1">s</span>)
<span class="pl-c1">10</span> <span class="pl-s1">loops</span>, <span class="pl-s1">best</span> <span class="pl-s1">of</span> <span class="pl-c1">3</span>: <span class="pl-c1">26.6</span> <span class="pl-s1">ms</span> <span class="pl-s1">per</span> <span class="pl-s1">loop</span></pre></div>
<p dir="auto">Memory stats not provided here but I've seen it explode (e.g. use 60+ GB RAM).</p>
<p dir="auto">An old issue, not sure if related: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="30024660" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/6697" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/6697/hovercard" href="https://github.com/pandas-dev/pandas/issues/6697">#6697</a>.</p>
<p dir="auto">Polish government provides <a href="http://www.pse.pl/index.php?dzid=78" rel="nofollow">data on power demand</a> with local timestamps. DST switches are unfortunately not accounted for, so some timestamps are duplicated. Thankfully, the differences aren't big to matter in some applications, but it seems the way these timestamps are provided in the file do not work with <code class="notranslate">tz_localize</code>, which seems to be the tool to fix this problem.</p>
<h4 dir="auto">Code Sample</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from pandas import Series, Timestamp
Series([14603.9, 14559.700000000001, 14239.0, 14371.0, 13914.5, 14427.200000000001, 14300.5, 14267.5, 14162.200000000001, 14148.5, 14028.1, 14083.1, 14122.9], index=[Timestamp('2015-10-25 01:30:00'), Timestamp('2015-10-25 01:45:00'), Timestamp('2015-10-25 02:00:00'), Timestamp('2015-10-25 02:00:00'), Timestamp('2015-10-25 02:15:00'), Timestamp('2015-10-25 02:15:00'), Timestamp('2015-10-25 02:30:00'), Timestamp('2015-10-25 02:30:00'), Timestamp('2015-10-25 02:45:00'), Timestamp('2015-10-25 02:45:00'), Timestamp('2015-10-25 03:00:00'), Timestamp('2015-10-25 03:15:00'), Timestamp('2015-10-25 03:30:00')]).tz_localize('Europe/Warsaw', ambiguous='infer')"><pre class="notranslate"><code class="notranslate">from pandas import Series, Timestamp
Series([14603.9, 14559.700000000001, 14239.0, 14371.0, 13914.5, 14427.200000000001, 14300.5, 14267.5, 14162.200000000001, 14148.5, 14028.1, 14083.1, 14122.9], index=[Timestamp('2015-10-25 01:30:00'), Timestamp('2015-10-25 01:45:00'), Timestamp('2015-10-25 02:00:00'), Timestamp('2015-10-25 02:00:00'), Timestamp('2015-10-25 02:15:00'), Timestamp('2015-10-25 02:15:00'), Timestamp('2015-10-25 02:30:00'), Timestamp('2015-10-25 02:30:00'), Timestamp('2015-10-25 02:45:00'), Timestamp('2015-10-25 02:45:00'), Timestamp('2015-10-25 03:00:00'), Timestamp('2015-10-25 03:15:00'), Timestamp('2015-10-25 03:30:00')]).tz_localize('Europe/Warsaw', ambiguous='infer')
</code></pre></div>
<h4 dir="auto">Current Output</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[…]
pandas/tslib.pyx in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:69085)()
AmbiguousTimeError: There are 4 dst switches when there should only be 1."><pre class="notranslate"><code class="notranslate">[…]
pandas/tslib.pyx in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:69085)()
AmbiguousTimeError: There are 4 dst switches when there should only be 1.
</code></pre></div>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">Obviously, we don't know what should be the exact result. My understanding of <code class="notranslate">ambiguous='infer'</code> is that at this point, I'm just letting <code class="notranslate">pandas</code> find some timezone assignment that is not totally wrong, because in some applications this will still be better than NaT. For example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2015-10-25 01:30:00+02:00    14603.9
2015-10-25 01:45:00+02:00    14559.7
2015-10-25 02:00:00+02:00    14239.0
2015-10-25 02:00:00+01:00    14371.0
2015-10-25 02:15:00+02:00    13914.5
2015-10-25 02:15:00+01:00    14427.2
2015-10-25 02:30:00+02:00    14300.5
2015-10-25 02:30:00+01:00    14267.5
2015-10-25 02:45:00+02:00    14162.2
2015-10-25 02:45:00+01:00    14148.5
2015-10-25 03:00:00+01:00    14028.1
2015-10-25 03:15:00+01:00    14083.1
2015-10-25 03:30:00+01:00    14122.9
dtype: float64"><pre class="notranslate"><code class="notranslate">2015-10-25 01:30:00+02:00    14603.9
2015-10-25 01:45:00+02:00    14559.7
2015-10-25 02:00:00+02:00    14239.0
2015-10-25 02:00:00+01:00    14371.0
2015-10-25 02:15:00+02:00    13914.5
2015-10-25 02:15:00+01:00    14427.2
2015-10-25 02:30:00+02:00    14300.5
2015-10-25 02:30:00+01:00    14267.5
2015-10-25 02:45:00+02:00    14162.2
2015-10-25 02:45:00+01:00    14148.5
2015-10-25 03:00:00+01:00    14028.1
2015-10-25 03:15:00+01:00    14083.1
2015-10-25 03:30:00+01:00    14122.9
dtype: float64
</code></pre></div>
<h4 dir="auto">output of <code class="notranslate">pd.show_versions()</code></h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [4]: pandas.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.9.final.0
python-bits: 64
OS: Linux
OS-release: 4.6.0-0.bpo.1-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_US.utf8

pandas: 0.18.1
nose: None
pip: 1.5.6
setuptools: 24.0.3
Cython: 0.24.1
numpy: 1.11.1
scipy: 0.17.1
statsmodels: None
xarray: None
IPython: 5.0.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
"><pre class="notranslate"><code class="notranslate">In [4]: pandas.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.9.final.0
python-bits: 64
OS: Linux
OS-release: 4.6.0-0.bpo.1-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_US.utf8

pandas: 0.18.1
nose: None
pip: 1.5.6
setuptools: 24.0.3
Cython: 0.24.1
numpy: 1.11.1
scipy: 0.17.1
statsmodels: None
xarray: None
IPython: 5.0.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None

</code></pre></div>