我不确定跟随你,但是你使用DataFrame.ix选择/设置单个元素:

In [79]: M

Out[79]:

one two three four

a -0.277981 1.500188 -0.876751 -0.389292

b -0.705835 0.108890 -1.502786 -0.302773

c 0.880042 -0.056620 -0.550164 -0.409458

d 0.704202 0.619031 0.274018 -1.755726

In [75]: M.ix[0]

Out[75]:

one -0.277981

two 1.500188

three -0.876751

four -0.389292

Name: a

In [78]: M.ix[0,0]

Out[78]: -0.27798082190723405

In [81]: M.ix[0,0] = 1.0

In [82]: M

Out[82]:

one two three four

a 1.000000 1.500188 -0.876751 -0.389292

b -0.705835 0.108890 -1.502786 -0.302773

c 0.880042 -0.056620 -0.550164 -0.409458

d 0.704202 0.619031 0.274018 -1.755726

In [84]: M.ix[(0,1),(0,1)] = 1

In [85]: M

Out[85]:

one two three four

a 1.000000 1.000000 -0.876751 -0.389292

b 1.000000 1.000000 -1.502786 -0.302773

c 0.880042 -0.056620 -0.550164 -0.409458

d 0.704202 0.619031 0.274018 -1.755726

您还可以按索引切片:

In [98]: M.ix["a":"c","one"] = 2.0

In [99]: M

Out[99]:

one two three four

a 2.000000 1.000000 -0.876751 -0.389292

b 2.000000 1.000000 -1.502786 -0.302773

c 2.000000 -0.056620 -0.550164 -0.409458

d 0.704202 0.619031 0.274018 -1.755726

pythonpandas设置索引_python – pandas:使用(row,col)索引设置值相关推荐

  1. python 重置索引_python pandas 对series和dataframe的重置索引reindex方法

    reindex更多的不是修改pandas对象的索引,而只是修改索引的顺序,如果修改的索引不存在就会使用默认的None代替此行.且不会修改原数组,要修改需要使用赋值语句. series.reindex( ...

  2. python附加索引_python – 附加两个多索引的pandas数据帧

    你能帮忙附上两个多索引的熊猫数据帧吗?试图将df_future附加到df_current. COMPANY和DATE是索引. df_current VALUE COMPANY DATE 7/27/20 ...

  3. python numpy矩阵索引_python – Numpy中的矩阵索引

    索引后查看形状: In [295]: A=np.matrix([1,2,3]) In [296]: A.shape Out[296]: (1, 3) In [297]: A[0] Out[297]: ...

  4. python 返回列表索引_python怎么返回列表元素索引?

    python中可以使用index()方法返回列表中指定元素的索引. Python index() 方法检测字符串中是否包含子字符串 str ,如果指定 beg(开始) 和 end(结束) 范围,则检查 ...

  5. python增加索引_python – 为numpy数组添加索引

    我有一个numpy数组: prob_rf = [[0.4, 0.4, 0.4], [0.5, 0.5, 0.5], [0.6, 0.6, 0.6]] 我想为每个内部数组添加一个索引号: prob_rf ...

  6. pandas重新设置列索引_python数据分析包Pandas(一)

    pandas是一个python包,提供快速,灵活和富有表现力的数据结构,旨在使"关系"或"标记"数据的使用既简单又直观. pandas的两个主要数据结构Seri ...

  7. python pandas dataframe 不显示索引_Python DataFrame 设置输出不显示index(索引)值的方法...

    Python DataFrame 设置输出不显示index(索引)值的方法 在输出代码行中,加入"index=False"如下: m_pred_survived.to_csv(&q ...

  8. pandas使用query函数基于判断条件获得dataframe中满足条件的数据行(row)的索引列表(index of rows matching conditions in dataframe)

    pandas使用query函数基于判断条件获得dataframe中满足条件的数据行(row)的索引列表(index of rows matching conditions in dataframe) ...

  9. pandas获取dataframe中索引值最大值所在的数据行(get dataframe row of max index value)

    pandas获取dataframe中索引值最大值所在的数据行(get dataframe row of max index value) 目录 pandas获取dataframe中索引值最大值所在的数 ...

最新文章

  1. SnowFlake唯一ID生成器
  2. CAS(compareAndSwap)原理
  3. 手持机连不上信道设置为13的AP
  4. 【三种可能问题】RuntimeError: cuDNN error: CUDNN_STATUS_NOT_SUPPORTED
  5. Python 常见优化技巧,让你的程序溜溜的跑起来!
  6. java数据跑不出来,6000条数据,java下跑了20多分钟了还没跑完,求教怎么改进
  7. 【深度学习】——物体检测细节处理(NMS、样本不均衡、遮挡物体)
  8. 序列化框架MJExtension详解 + iOS ORM框架
  9. webpack 优化react项目没有解决的问题
  10. HNUCM 1284:二叉树遍历
  11. 如何在网页中添加 GitHub Corners
  12. JSP中文乱码解决方案了解和TOMCAT中文乱码解决
  13. 快讯:预装Ubuntu 11.10小电脑南非开卖
  14. flow java.lang.IllegalArgumentException: Unable to create call adapter for
  15. 0428-项目再开发2.0
  16. 在windows下启动容器时,报 the input device is not a TTY. If you are using mintty, try prefixing the command
  17. 浅谈AutoCAD下载安装的那些三两事!
  18. android 重启后进入安全模式_Android手机如何进入离开安全模式?
  19. python什么意思d_python里d是什么意思
  20. rebar3使用介绍(三)命令

热门文章

  1. .net之 datagrid
  2. C#实现javascript的escape
  3. 用神经网络分类陀螺和遥远星体
  4. pageinfo对合并list进行分页_Pagehelper不是特别好用。对list直接分页
  5. 【控制】《多智能体机器人系统信息融合与协调》范波老师-第6章-基于分布式强化学习的多 Agent 协调方法
  6. 【数理知识】《数值分析》李庆扬老师-第3章-函数逼近与快速傅里叶变换
  7. 工作project里的Verilog记录
  8. 互相关延时估计加权函数性能分析
  9. if/ else 你真的会吗?
  10. 【极值问题】【CF1063B】 Labyrinth