Skip to content

Series.str.contains doesn't correct if series contains only nan values. #14171

Closed
@ponomarevvl90

Description

@ponomarevvl90

Code Sample, a copy-pastable example if possible

import pandas as pd
import numpy as np
import re

CONTAINS_REG_EXP = ur'{0}'
value = '3'
t1 = pd.Series(data=[np.nan, np.nan, np.nan], dtype=np.object)
t2 = t1.str.contains(CONTAINS_REG_EXP.format(re.escape(value)),
                                  flags=re.U, na=False)
print t2

Expected Output

0    False
1    False
2    False
dtype: bool

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Linux
OS-release: 4.2.0-42-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: None
pip: 8.0.3
setuptools: 18.0.1
Cython: 0.23.4
numpy: 1.10.1
scipy: None
statsmodels: None
IPython: 4.0.1
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.4.6
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
Jinja2: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions