【发布时间】:2021-03-22 06:21:12
【问题描述】:
我的列表存储在info 中,其中包含 -
['Stephanie Ramirez', 'Greater Tampa Bay Area', '500+ connections', 'Jacobs', 'Technical Recruiter', '2019 – Present', '2 yrs']
我希望它如何出现在数据框中,以便以后可以将其导出到 excel 文件中,例如 -
| name | location | connection | company | position | duration | tenure |
|---|---|---|---|---|---|---|
| Stephanie Ramirez | Greater Tampa Bay Area | 500+ connections | Jacobs | Technical Recruiter | 2019 – Present | 2 yrs |
这是我的代码,它提取数据并附加到info
name_div = soup.find('div', {'class': 'flex-1 mr5'})
name_loc = name_div.find_all('ul')
name = name_loc[0].find('li').get_text().strip()
loc = name_loc[1].find('li').get_text().strip()
connection = name_loc[1].find_all('li')
connection = connection[1].get_text().strip()
info = []
info.append(name)
info.append(loc)
info.append(connection)
info
['Stephanie Ramirez', 'Greater Tampa Bay Area', '500+ connections']
#experience setion
exp_section = soup.find('section', {'id': 'experience-section'})
exp_section = exp_section.find('ul')
div_tag = exp_section.find('div')
a_tag = div_tag.find('a')
job_title = a_tag.find('h3').get_text().strip()
company_name = a_tag.find_all('p')[1].get_text().strip()
joining_date = a_tag.find_all('h4')[0].find_all('span')[1].get_text().strip()
exp = a_tag.find_all('h4')[1].find_all('span')[1].get_text().strip()
info.append(company_name)
info.append(job_title)
info.append(joining_date)
info.append(exp)
info
['Stephanie Ramirez', 'Greater Tampa Bay Area', '500+ connections', 'Jacobs', 'Technical Recruiter', '2019 – Present', '2 yrs']
请帮助我在数据框中获得所需的 OP。 提前致谢!!
只是问一下,我发布问题的方式是否正确?
【问题讨论】:
标签: pandas dataframe jupyter-notebook