1
두 개의 데이터 열에 팀 이름과 행이 필요합니다. 그러나 모든 내 입력은 B1 셀에 배치됩니다. (주석의 끝 부분에 주석 처리 된 코드가 있음을 참고하십시오). 모든 팀을 A 열과 B 열로 줄이기 위해 for 루프로 목록을 반복해야하지만 팬더로 수행하는 동안 내 머리를 감쌀 수는 없다고 생각합니다. 어떤 도움이라도 대단히 감사하겠습니다! 당신은리스트의 목록을 만들고 있기 때문에이 작업을 수행해서는 안Python - 판다를 사용하여 Excel 스프레드 시트로 데이터 서식 지정
감사
다음team = []
line = []
# Each row in table find all rows with class name team
for tr in table.find_all("tr", class_="team"):
# Place all text with identifier 'name' in list named team
for td in tr.find_all("td", ["name"]):
team.append(td.text.strip())
for tr in table.find_all("tr", class_="team"):
for td in tr.find_all("td", ["currentline"]):
line.append(td.text.strip())
# Amount of data in lists
x = len(team)
# Team name is list team, Line in list line. Create relationship between both data sets
# Creating Excel Document and Placing Team Name in column A, Placing Line in Column B
#Need to add data into Excel somehow
for i in range(0,1):
for j to line:
""" data = {'Team':[team], 'line' : [line]}
table = pd.DataFrame(data)
writer = pd.ExcelWriter('Scrape.xlsx')
table.to_excel(writer, 'Scrape 1')
writer.save()"""
귀하의 주석 코드가 무엇을 생산하면 내 테스트를 원해. – bernie
내 모든 결과를 B1 셀에 넣습니다. 팀을 한 열에, 다른 열을 다른 열에 넣기를 원합니다. 말이 돼? @bernie –
내 테스트에서 출력은 원하는대로하는 것입니다. – bernie