Как убрать числа в Python Pandas Dataframe? - PullRequest
0 голосов
/ 02 марта 2020

Это My DataFrame

                                                 col
0  1. This is the most beautiful place in the world.
1  2. This man has more skills to show in cricket...
2  3. That’s exactly I wanted to become, a highes...
3  4. We are deeply finanicaial to co-creating sc...
4      5. Company proximate to our operations liv...
5     6. Dot chain management is key to the opera...
6  7. Diversity within our workforce is of paramo...
7  8. The Indian scrap industry is highly fragmen...
8       9. Steel has progressively met the challe...

Выходные данные должны иметь следующий формат:

                                                 col
0     This is the most beautiful place in the world.
1  This man has more skills to show in cricket th...
2  That’s exactly I wanted to become, a highest r...
3   We are deeply finanicaial to co-creating scal...
4         Company proximate to our operations liv...
5        Dot chain management is key to the opera...
6     Diversity within our workforce is of paramo...
7     The Indian scrap industry is highly fragmen...
8          Steel has progressively met the challe...

1 Ответ

3 голосов
/ 02 марта 2020

Используйте Series.str.replace с regex - ^ для начала строки, \d+ для одной или нескольких цифр, \. экранируется . и \s+ является для одного или нескольких пробелов:

df['col'] = df['col'].str.replace(r'^\d+\.\s+','')

Если максимальное число равно 9, удалите первые 3 значения по позиции с индексированием:

df['col'] = df['col'].str[3:]

print (df)
                                                 col
0     This is the most beautiful place in the world.
1  This man has more skills to show in cricket th...
2  That’s exactly I wanted to become, a highest r...
3   We are deeply finanicaial to co-creating scal...
4         Company proximate to our operations liv...
5        Dot chain management is key to the opera...
6     Diversity within our workforce is of paramo...
7     The Indian scrap industry is highly fragmen...
8          Steel has progressively met the challe...
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...