콘솔워크

pandas.Series.str.match 특정 단어와 완전 일치하는 데이터 필터링 본문

프로그래밍/python

pandas.Series.str.match 특정 단어와 완전 일치하는 데이터 필터링

이휘재123 2022. 9. 27. 15:23
반응형
    # 처방
    def get_df_prescribed(self):
        df_prescribed = self.df_order.loc[self.df_order["처방구분"].str.match("처방")]
        print(df_prescribed)
        return df_prescribed

    # 비처방
    def get_df_not_prescribed(self):
        df_not_prescribed = self.df_order.loc[self.df_order["처방구분"].str.match("비처방")]
        print(df_not_prescribed)
        return df_not_prescribed

contains로는 겹쳐버리는 문자가 있으면 걸러내지 못하는 데이터를 match를 이용해서 걸러낸다.

반응형