Код: Выделить всё
df = pd.DataFrame({'Names': ["Absolute Neutrophil Count","Absolute Lymphocyte Count 2.9",
"Absolute Neutrophil Count 10.2","ESR (Modified Westergren) 8",
"Free Triiodothyronine (FT3) 3.59",
"Free Triiodothyronine FT4 4.53"]})
df
Код: Выделить всё
Names
0 Absolute Neutrophil Count
1 Absolute Lymphocyte Count 2.9
2 Absolute Neutrophil Count 10.2
3 ESR (Modified Westergren) 8
4 Free Triiodothyronine (FT3) 3.59
5 Free Triiodothyronine FT4 4.53
Код: Выделить всё
0 Missing/None
1 2.9
2 10.2
3 8
4 3.59
5 4.53
Код: Выделить всё
df.iloc[:,0].str.extract(r'^(.*?)\s*(\d\.?\d*)?$') # '\d+\.\d+'
Код: Выделить всё
0 1
0 Absolute Neutrophil Count NaN
1 Absolute Lymphocyte Count 2.9
2 Absolute Neutrophil Count 1 0.2
3 ESR (Modified Westergren) 8
4 Free Triiodothyronine (FT3) 3.59
5 Free Triiodothyronine FT4 4.53
Подробнее здесь: https://stackoverflow.com/questions/791 ... -in-python
Мобильная версия