Pandas数据操作与缺失值处理全解析
1. Pandas索引的特性
Pandas的索引具有不可变的特性,这一特性使得在多个DataFrame和数组之间共享索引更加安全,避免了因意外修改索引而产生的副作用。例如,尝试对索引进行赋值操作会引发 TypeError
:
ind[1] = 0
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-34-40e631c82e8a> in <module>()
----> 1 ind[1] = 0
/Users/jakevdp/anaconda/lib/python3.5/site-packages/pandas/indexes/base.py ...
1243
1244 def __setitem__(self, key, value):
-> 1245 raise TypeError("Index does not support mutable operations")
1246
1247 def __getitem__(self, key):
TypeError: Index does not support mutable operations
同时,Pandas的