简体   繁体   English

如何为 pandas 数据库中的特定行和列分配值?

[英]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.

相关问题 如何按名称为特定的行和列赋值? - How do I assign a value to a specific row and column by name? 如何使用计算值在 pandas 中创建新列并为每一行分配特定值? - How do I create a new column in pandas using calculated values and assign specific values to each row? Pandas数据框架如何根据特定组和上一行值为列分配值 - Pandas dataframe how to assign value to a column basing on a specific group and previous row value 我如何选择与列列表具有相同对应值的行中的特定项目 - Pandas Pyhton - How do i pick a specific item in a row that has the same corresponding value with the column list - Pandas Pyhton 如何将索引 1 处特定列的值分配给新变量 - How do I assign to a new variable the value of a specific column at index 1 当特定列包含向我发出信号应删除该行的值时,如何删除Pandas数据框中的行? - How do I delete a row in Pandas dataframe when a specific column contains a value that signals to me that the row should be deleted? 如何从 pandas dataframe 的行中删除特定值? - How do I remove a specific value from a row in a pandas dataframe? 如何获取连续熊猫中具有最高值的列的名称 - How do I get the name of the column with the highest value in a row pandas 在 pandas dataframe 中,如何根据列值过滤行,进行计算并将结果分配给新列? - In a pandas dataframe, how can I filter the rows based on a column value, do calculation and assign the result to a new column? 如何为pandas栏赋值? - how to assign value to the pandas column?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM