Я ищу подстроку или несколько подстрок в dataframe из 4 миллионов строк.Как сделать pandas dataframe str.contains быстрее искать
df[df.col.str.contains('Donald',case=True,na=False)]
или
df[df.col.str.contains('Donald|Trump|Dump',case=True,na=False)]
DataFrame (ДФ) выглядит, как показано ниже (4 миллиона строк строк)
df = pd.DataFrame({'col': ["very definition of the American success story, continually setting the standards of excellence in business, real estate and entertainment.",
"The myriad vulgarities of Donald Trump—examples of which are retailed daily on Web sites and front pages these days—are not news to those of us who have",
"While a fearful nation watched the terrorists attack again, striking the cafés of Paris and the conference rooms of San Bernardino"]})
Есть ли наконечник, чтобы сделать эту строку поиска быстрее? Например, сначала сортировка данных, определенный способ индексирования, изменение имен столбцов на номера, сброс «na = False» из запроса и т. Д.? Даже миллисекунды увеличения скорости будут очень полезны!