熊猫数据框过滤器包含('。'),Python 3.6

时间:2020-08-11 11:22:15

标签: python python-3.x pandas dataframe

我有一个数据框架,其中包含1947-2019年的年份,但是一行包含“ 2018.1”。 当我过滤日期中包含“。”的数据时,结果将给出所有数据

DataAll.loc[DataAll['Date'].astype(str).str.contains('.'), 'Date']

我已经检查了数据类型,并且都在字符串中

DataAll['Date'].apply(type).unique()
array([<class 'str'>], dtype=object)

如何过滤包含“。”的数据,请帮忙。

1 个答案:

答案 0 :(得分:3)

这里是with fits.open(filename) as hdul: maxvalue1, spec1, d1, he1, hdu_gray, coord1 = fix_fitshead(hdul) ... 个特殊的正则表达式字符,因此需要.或对其进行转义:

regex=False

DataAll.loc[DataAll['Date'].astype(str).str.contains('.', regex=False), 'Date']
相关问题