def match_track(self, artist, song): """ Returns rows that match on both artist and song name text. """ artist, song = denoise(artist), denoise(song) pieces = song.split(' ') for ignore in ['cover', 'preview', 'mashup']: if ignore in pieces: return False frame = self.match_field('artist_dn', artist) indexes = frame['name_dn'].str.contains(song, case=False).fillna(False) return not frame[indexes].empty
def match_field(self, field, text): """ Returns indexes of rows that have the given text in the given row. """ text = escape_for_regex(denoise(text)) return self[self[field].str.contains(text, case=False).fillna(False)]