【发布时间】:2021-05-25 13:09:37
【问题描述】:
type(df['Soft_skills'][0])
>>>str
我需要像这样输出
df['Soft_skills'][0] = Management,Decision Making
第二行
df['Soft_skills'][1] = None
我不知道如何删除 " 并将其转换为 strformat。
>>> df['Soft_skills']
0 ["Management", "Decision Making"]
1 []
2 ["Management"]
3 []
4 ["Governance", "Management", "Leadership", "Te...
...
1229 []
1230 []
1231 []
1232 ["Agenda (Meeting)", "Governance"]
1233 []
Name: Soft_skills, Length: 1234, dtype: object
在某些情况下,数据是
The syllabus for this course will cover the following:, \n, *, The nature and purpose of cost and management accounting, \n, *, Source documents and coding, \n, *, Cost classification and measuring, \n, *, Recording costs, \n, *, Spreadsheets
我通过使用替换它
d = {
'Not Mentioned':'',
"\r\n": "\n",
"\r": "\n",
'\u00a0':' ',
': \n, *, ':'\n * ',
' \n,':'\n',
}
df=df.replace(d.keys(),d.values(),regex=True)
但是当我尝试时,没有什么可以替代问题是什么我错过了什么? 我也用过这个
df['Course_content'] = df['Course_content']\
.str.replace('Not Mentioned','')\
.str.replace("\r\n", "\n")\
.str.replace("\r", "\n")\
.str.replace('\u00a0',' ')\
.str.replace(', \n, *, ','\n * ')\
.str.replace(' \n,','\n')
但它也不适合我
【问题讨论】:
-
您可以运行
print(df.head(10).to_dict())并将输出粘贴到您的问题中吗?