【发布时间】:2021-07-26 04:10:49
【问题描述】:
我有一个数据框: 例如:
df =
Questions Answers
Where is Amazon? Brazil
Is he a scientist? No
Did he stole my money? Yes
What does your father do? Business
He is a great player. I don't think so.
She is my girlfriend. I too agree.
我想在条件下从上面的数据框创建三个数据框:
df1 的条件:
如果 df['Questions'] 的第一个单词来自列表:
# list of Yes/No verbs
yn_list = ['Do','Does','Did','do','does','did','Am','Are','Is','Was','Were','am','are','is','was','were',
'Have','Has','Had','have','has','had','Will','Would','Shall','Should','Can','Could','May',
'Might','will','would','shall','should','can','could','may','might']
# list of negative Yes/No verbs
yn_negative_list = ["Don't","Doesn't","Didn't","don't","doesn't","didn't","Aren't","Isn't","aren't","isn't",
"Wasn't","Weren't","wasn't","weren't","Haven't","Hasn't","Hadn't","haven't","hasn't",
"hadn't","Won't","Wouldn't","won't","wouldn't","Shan't","shan't","Shouldn't","Can't",
"Couldn't","shouldn't","can't","couldn't","may not","May not","Mightn't","mightn't"]
df2 的条件:
如果 df['Questions'] 的第一个单词来自列表:
wh_list = ['who','where','what','when','why','whom','which','whose','how']
df3 的条件:
如果句子以“.”结尾签到
【问题讨论】:
标签: python python-3.x pandas list dataframe