<p dir="auto">Hi folks,</p>
<p dir="auto">In Pandas 0.23.0 (on Linux Mint 18.3), i run</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd
import numpy as np


s = pd.Series([np.nan, 1])
s.fillna(-1).astype(int).astype(str).replace('-1', '')"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</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">nan</span>, <span class="pl-c1">1</span>])
<span class="pl-s1">s</span>.<span class="pl-en">fillna</span>(<span class="pl-c1">-</span><span class="pl-c1">1</span>).<span class="pl-en">astype</span>(<span class="pl-s1">int</span>).<span class="pl-en">astype</span>(<span class="pl-s1">str</span>).<span class="pl-en">replace</span>(<span class="pl-s">'-1'</span>, <span class="pl-s">''</span>)</pre></div>
<p dir="auto">and get the error</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-39-6bd382c335e3&gt; in &lt;module&gt;()
      1 print(pd.__version__)
      2 s = pd.Series([np.nan, 1])
----&gt; 3 s.fillna(-1).astype(int).astype(str).replace('-1', '')

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/series.py in replace(self, to_replace, value, inplace, limit, regex, method)
   3427         return super(Series, self).replace(to_replace=to_replace, value=value,
   3428                                            inplace=inplace, limit=limit,
-&gt; 3429                                            regex=regex, method=method)
   3430 
   3431     @Appender(generic._shared_docs['shift'] % _shared_doc_kwargs)

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/generic.py in replace(self, to_replace, value, inplace, limit, regex, method)
   5877                     new_data = self._data.replace(to_replace=to_replace,
   5878                                                   value=value, inplace=inplace,
-&gt; 5879                                                   regex=regex)
   5880                 else:
   5881                     msg = ('Invalid &quot;to_replace&quot; type: '

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/internals.py in replace(self, **kwargs)
   3718 
   3719     def replace(self, **kwargs):
-&gt; 3720         return self.apply('replace', **kwargs)
   3721 
   3722     def replace_list(self, src_list, dest_list, inplace=False, regex=False,

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/internals.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs)
   3579 
   3580             kwargs['mgr'] = self
-&gt; 3581             applied = getattr(b, f)(**kwargs)
   3582             result_blocks = _extend_blocks(applied, result_blocks)
   3583 

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/internals.py in replace(self, to_replace, value, inplace, filter, regex, convert, mgr)
   2430         blocks = [self]
   2431 
-&gt; 2432         if not either_list and is_re(to_replace):
   2433             return self._replace_single(to_replace, value, inplace=inplace,
   2434                                         filter=filter, regex=True,

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/dtypes/inference.py in is_re(obj)
    217     &quot;&quot;&quot;
    218 
--&gt; 219     return isinstance(obj, re_type)
    220 
    221 

/usr/lib/python3.5/typing.py in __instancecheck__(self, obj)
    258 
    259     def __instancecheck__(self, obj):
--&gt; 260         raise TypeError(&quot;Type aliases cannot be used with isinstance().&quot;)
    261 
    262     def __subclasscheck__(self, cls):

TypeError: Type aliases cannot be used with isinstance()."><pre class="notranslate"><code class="notranslate">---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-39-6bd382c335e3&gt; in &lt;module&gt;()
      1 print(pd.__version__)
      2 s = pd.Series([np.nan, 1])
----&gt; 3 s.fillna(-1).astype(int).astype(str).replace('-1', '')

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/series.py in replace(self, to_replace, value, inplace, limit, regex, method)
   3427         return super(Series, self).replace(to_replace=to_replace, value=value,
   3428                                            inplace=inplace, limit=limit,
-&gt; 3429                                            regex=regex, method=method)
   3430 
   3431     @Appender(generic._shared_docs['shift'] % _shared_doc_kwargs)

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/generic.py in replace(self, to_replace, value, inplace, limit, regex, method)
   5877                     new_data = self._data.replace(to_replace=to_replace,
   5878                                                   value=value, inplace=inplace,
-&gt; 5879                                                   regex=regex)
   5880                 else:
   5881                     msg = ('Invalid "to_replace" type: '

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/internals.py in replace(self, **kwargs)
   3718 
   3719     def replace(self, **kwargs):
-&gt; 3720         return self.apply('replace', **kwargs)
   3721 
   3722     def replace_list(self, src_list, dest_list, inplace=False, regex=False,

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/internals.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs)
   3579 
   3580             kwargs['mgr'] = self
-&gt; 3581             applied = getattr(b, f)(**kwargs)
   3582             result_blocks = _extend_blocks(applied, result_blocks)
   3583 

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/internals.py in replace(self, to_replace, value, inplace, filter, regex, convert, mgr)
   2430         blocks = [self]
   2431 
-&gt; 2432         if not either_list and is_re(to_replace):
   2433             return self._replace_single(to_replace, value, inplace=inplace,
   2434                                         filter=filter, regex=True,

~/.virtualenvs/make_gtfs-2RAnZ_bf/lib/python3.5/site-packages/pandas/core/dtypes/inference.py in is_re(obj)
    217     """
    218 
--&gt; 219     return isinstance(obj, re_type)
    220 
    221 

/usr/lib/python3.5/typing.py in __instancecheck__(self, obj)
    258 
    259     def __instancecheck__(self, obj):
--&gt; 260         raise TypeError("Type aliases cannot be used with isinstance().")
    261 
    262     def __subclasscheck__(self, cls):

TypeError: Type aliases cannot be used with isinstance().
</code></pre></div>
<p dir="auto">I expect to get what i got using Pandas 0.22.0, namely</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0     
1    1
dtype: object"><pre class="notranslate"><code class="notranslate">0     
1    1
dtype: object
</code></pre></div>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="pd.Series(['a', 'b', 'c']).replace('a', 'x')"><pre class="notranslate"><span class="pl-s1">pd</span>.<span class="pl-v">Series</span>([<span class="pl-s">'a'</span>, <span class="pl-s">'b'</span>, <span class="pl-s">'c'</span>]).<span class="pl-en">replace</span>(<span class="pl-s">'a'</span>, <span class="pl-s">'x'</span>)</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">This raises the following error:</p>
<blockquote>
<p dir="auto">TypeError: Type aliases cannot be used with isinstance().</p>
</blockquote>
<p dir="auto">This behavior is exclusive to the new <strong>version 0.23</strong>. Previous versions work as expected.</p>
<p dir="auto">Full traceback</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-75-761515b509b4&gt; in &lt;module&gt;()
----&gt; 1 pd.Series(['a','b','c']).replace('a', 'x')

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/series.py in replace(self, to_replace, value, inplace, limit, regex, method)
   3427         return super(Series, self).replace(to_replace=to_replace, value=value,
   3428                                            inplace=inplace, limit=limit,
-&gt; 3429                                            regex=regex, method=method)
   3430
   3431     @Appender(generic._shared_docs['shift'] % _shared_doc_kwargs)

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/generic.py in replace(self, to_replace, value, inplace, limit, regex, method)
   5877                     new_data = self._data.replace(to_replace=to_replace,
   5878                                                   value=value, inplace=inplace,
-&gt; 5879                                                   regex=regex)
   5880                 else:
   5881                     msg = ('Invalid &quot;to_replace&quot; type: '

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/internals.py in replace(self, **kwargs)
   3718
   3719     def replace(self, **kwargs):
-&gt; 3720         return self.apply('replace', **kwargs)
   3721
   3722     def replace_list(self, src_list, dest_list, inplace=False, regex=False,

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/internals.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs)
   3579
   3580             kwargs['mgr'] = self
-&gt; 3581             applied = getattr(b, f)(**kwargs)
   3582             result_blocks = _extend_blocks(applied, result_blocks)
   3583

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/internals.py in replace(self, to_replace, value, inplace, filter, regex, convert, mgr)
   2430         blocks = [self]
   2431
-&gt; 2432         if not either_list and is_re(to_replace):
   2433             return self._replace_single(to_replace, value, inplace=inplace,
   2434                                         filter=filter, regex=True,

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/dtypes/inference.py in is_re(obj)
    217     &quot;&quot;&quot;
    218
--&gt; 219     return isinstance(obj, re_type)
    220
    221

/usr/lib/python3.5/typing.py in __instancecheck__(self, obj)
    256
    257     def __instancecheck__(self, obj):
--&gt; 258         raise TypeError(&quot;Type aliases cannot be used with isinstance().&quot;)
    259
    260     def __subclasscheck__(self, cls):

TypeError: Type aliases cannot be used with isinstance()."><pre class="notranslate"><code class="notranslate">---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-75-761515b509b4&gt; in &lt;module&gt;()
----&gt; 1 pd.Series(['a','b','c']).replace('a', 'x')

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/series.py in replace(self, to_replace, value, inplace, limit, regex, method)
   3427         return super(Series, self).replace(to_replace=to_replace, value=value,
   3428                                            inplace=inplace, limit=limit,
-&gt; 3429                                            regex=regex, method=method)
   3430
   3431     @Appender(generic._shared_docs['shift'] % _shared_doc_kwargs)

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/generic.py in replace(self, to_replace, value, inplace, limit, regex, method)
   5877                     new_data = self._data.replace(to_replace=to_replace,
   5878                                                   value=value, inplace=inplace,
-&gt; 5879                                                   regex=regex)
   5880                 else:
   5881                     msg = ('Invalid "to_replace" type: '

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/internals.py in replace(self, **kwargs)
   3718
   3719     def replace(self, **kwargs):
-&gt; 3720         return self.apply('replace', **kwargs)
   3721
   3722     def replace_list(self, src_list, dest_list, inplace=False, regex=False,

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/internals.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs)
   3579
   3580             kwargs['mgr'] = self
-&gt; 3581             applied = getattr(b, f)(**kwargs)
   3582             result_blocks = _extend_blocks(applied, result_blocks)
   3583

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/internals.py in replace(self, to_replace, value, inplace, filter, regex, convert, mgr)
   2430         blocks = [self]
   2431
-&gt; 2432         if not either_list and is_re(to_replace):
   2433             return self._replace_single(to_replace, value, inplace=inplace,
   2434                                         filter=filter, regex=True,

~/.virtualenvs/new/lib/python3.5/site-packages/pandas/core/dtypes/inference.py in is_re(obj)
    217     """
    218
--&gt; 219     return isinstance(obj, re_type)
    220
    221

/usr/lib/python3.5/typing.py in __instancecheck__(self, obj)
    256
    257     def __instancecheck__(self, obj):
--&gt; 258         raise TypeError("Type aliases cannot be used with isinstance().")
    259
    260     def __subclasscheck__(self, cls):

TypeError: Type aliases cannot be used with isinstance().
</code></pre></div>
<h4 dir="auto">Expected Output</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0    x
1    b
2    c
dtype: object"><pre class="notranslate"><code class="notranslate">0    x
1    b
2    c
dtype: object
</code></pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.5.1.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.13.13-5-pve<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: en_US.UTF-8<br>
LANG: en_US.UTF-8<br>
LOCALE: en_US.UTF-8</p>
<p dir="auto">pandas: 0.23.0<br>
pytest: None<br>
pip: 8.1.1<br>
setuptools: 20.7.0<br>
Cython: None<br>
numpy: 1.14.3<br>
scipy: 1.1.0<br>
pyarrow: None<br>
xarray: None<br>
IPython: 6.4.0<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.1<br>
pytz: 2018.4<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: 2.2.2<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 0.999<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.10<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>