Pandas:将布尔索引的边缘情况转换为空的DataFrame

时间:2012-10-03 00:13:49

标签: python dataframe pandas

我正在使用pandas 0.8.1

创建非空DataFrame:

import pandas
blah = pandas.DataFrame(numpy.empty([1, 1]), columns=['A'], index=pandas.DatetimeIndex(['2008-01-01']))
blah[numpy.array([true], bool)]

            A
2008-01-01  0

blah[numpy.array([True], bool)] = 0.0

这一切都很好,但在空的情况下:

blah = pandas.DataFrame(numpy.empty([0, 1]), columns=['A'], index=pandas.DatetimeIndex([]))
blah[numpy.array([], bool)]

Empty DataFrame
...

blah[numpy.array([], bool)] = 0.0

Traceback (most recent call last):
...
IndexError: invalid index

那不对,是吗?

0 个答案:

没有答案