[英]How do I assign a value to a specific row and column in a pandas database?
I have an integer:我有一个 integer:
num = 1
,and a database table points
: ,和一个数据库表points
:
X Y
0
1
2
3
How would I go about placing num
into column X
and field 3
using pandas? go 如何使用 pandas 将num
放入X
列和字段3
?
I have searched around and found points.ix[]
, which selects a specific row but using this I get an error message:我四处搜索并找到points.ix[]
,它选择了一个特定的行,但使用它我收到一条错误消息:
AttributeError: 'DataFrame' object has no attribute 'ix'
Apart from this I can't find anything else.除此之外,我找不到其他任何东西。
you can also try, df.iat[3,0]你也可以试试,df.iat[3,0]
Thanks谢谢
pandas.DataFrame.ix
deprecated since version 0.20.0 pandas.DataFrame.ix
自版本 0.20.0 起已弃用
You can use df.loc[3, 'X']
for the same result.您可以使用df.loc[3, 'X']
获得相同的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.