我有一个从API拉出来的Dataframe,但是当我尝试向这个Dataframe添加列时,所有条目都以NaN形式出现。我知道当我真正尝试将系列添加到Dataframe时必定存在一个问题,因为我单独返回了系列并且它们很好。这是我使用的代码:
account = pd.Series([Acct.name]*len(frame.index))
frame['Account'] = account
date = pd.Series([st]*len(frame.index))
frame['Date'] = date
答案 0 :(得分:0)
Acct.name和st只是我想要添加到列中的值,将我的代码更改为:
frame['Account'] = pd.Series([Acct.name]*len(frame.index))
frame['Date'] = pd.Series([st]*len(frame.index))
它有效..