0
我想通过给出行和列来元素访问熊猫DataFrame;对我来说似乎很简单,但研究并没有给出答案。我能走到今天:通过索引/列条目访问和编辑pandas.DataFrame
import pandas as pd
import numpy as np
data=np.random.randn(3,3)
index=np.linspace(0.1,1,3)
columns=np.linspace(2000,3000,3)
pdf=pd.DataFrame(data, index=index, columns=columns)
我发现pdf.ix
访问,但它给了我一个NaN
,我不能编辑条目:
pdf.ix[['0.55'],['2500']]
Out[16]:
2500
0.55 NaN
pdf.ix[['0.55'],['2500']]=2
KeyError: "['0.55'] not in index"
感谢您的帮助!
你不应该使用字符串,但实际数值:'pdf.ix [0.55,2500]' – joris