我正在尝试从列表中获取值并将其存储到数据框中
if
我的else
输出:
while (rank < len(get_rank)) and (summoner_name < len(get_summoner_name)) and (tier < len(get_tier)) and (lp < len(get_LP)) and (wr < len(get_wr)):
contains1 = get_rank[rank]
rank += 1
rank_list = [rank for rank in contains1]
df = pd.DataFrame({'A':rank_list[0]},index = [0])
print(df)
我的rank_list
输出:
[1]
[2]
[3]
我当前的输出:
rank_list[0]
我想要的输出:
1
2
3
答案 0 :(得分:1)
我相信您可以将contains1
的第一个值附加到列表中,然后由构造函数进行循环创建DataFrame
:
L = []
while (rank < len(get_rank)) and (summoner_name < len(get_summoner_name)) and (tier < len(get_tier)) and (lp < len(get_LP)) and (wr < len(get_wr)):
rank = get_rank[rank]
summoner_name = get_summoner_name[rank]
tier = get_tier[rank]
lp = get_lp[rank]
wr = get_wr[rank]
d = {'rank':rank,
'summoner_name':summoner_name,
'tier':tier,
'lp':lp,
'wr':wr}
L.append(d)
df = pd.DataFrame(L)
print(df)
答案 1 :(得分:0)
df = pd.DataFrame(rank_list [0],列= ['A'])