对于我来说,下面的代码片段将NaN值保留为NaN:
import pandas
a = [12, 23]
b = [123, None]
c = [1234, 2345]
d = [12345, 23456]
tuples = [('eyes', 'left'), ('eyes', 'right'), ('ears', 'left'), ('ears', 'right')]
events = {('eyes', 'left'): a, ('eyes', 'right'): b, ('ears', 'left'): c, ('ears', 'right'): d}
multiind = pandas.MultiIndex.from_tuples(tuples, names=['part', 'side'])
zed = pandas.DataFrame(events, index=['a', 'b'], columns=multiind)
zed['eyes']['right'].fillna(value=555, inplace=True)
我得到:
^{pr2}$如果我在inplace
设置为False的情况下运行此函数,则返回的序列已将NaN
替换为555。我可以使用这种变通方法,但一方面,如果是一个bug,我想报告它;另一方面,即使是变通方法也不适用于我的实际应用程序。在
所以问题是我是否误解了fillna()
还是这是一个bug。谢谢!在
编辑: 我在opensuse13.1上使用pandas 0.12.0、numpy 1.8.0和python2.7.5。在
^{} 的意思是用其他东西替换{}值,而不是将
NaN
插入空数据槽中。有关详细信息,请参见this example:注意
NaT
不是时间。在相关问题 更多 >
编程相关推荐