2024-09-29 01:25:48 发布
网友
如何使用Python从Excel中提取单词并使其成为单独的列? 例如:blow文本在excel表格中,我想提取“血型”并使其成为新的克隆
血型-O阳性,HIV/HBsAg/HCV-阴性
这取决于你到底想提取什么。如果是allways血型,那么你可以只使用一个切片,如果你想提取的是不同的单词,那么你需要提供更多的细节,以便任何人能够正确地帮助你
让我知道更多的细节是什么,你正在寻找
因此,假设您的数据如下所示:
我们可以做到:
import pandas as pd data = pd.read_csv('doc.csv')
得到
最后
split_by_comma = data.col1.str.split(',').tolist() blood_group = [lst[0].split('- ')[1] for lst in split_by_comma] hiv = [lst[1].split('- ')[1] for lst in split_by_comma] pd.DataFrame({'Blood Group': blood_group, 'HIV/HBsAg/HCV': hiv})
要获得此信息:
这取决于你到底想提取什么。如果是allways血型,那么你可以只使用一个切片,如果你想提取的是不同的单词,那么你需要提供更多的细节,以便任何人能够正确地帮助你
让我知道更多的细节是什么,你正在寻找
因此,假设您的数据如下所示:
我们可以做到:
得到
最后
要获得此信息:
相关问题 更多 >
编程相关推荐