我很困惑,这很简单,但我没有立即在StackOverflow上找到答案:
df.set_index('xcol')使列'xcol'成为索引(当它是df列时).
df.set_index('xcol')
'xcol'
df.reindex(myList)但是,从数据框外部获取索引,例如,从myList我们在其他地方定义的名称列表中获取索引.
df.reindex(myList)
myList
我希望这篇文章澄清一下!欢迎增加这篇文章!
python indexing python-3.x pandas reindex
indexing ×1
pandas ×1
python ×1
python-3.x ×1
reindex ×1