当我用自定义索引值创建新的DataFrame时,它用NaN/NaT值替换列中的数据。你知道吗
我试过分配pd索引作为index
参数,结果也是一样的。你知道吗
pd.DataFrame(
data={
"date": pd.Series([datetime(2000, 1, 2)]),
"duration": pd.Series([datetime(1970, 1, 1, 0, 5)]),
}
index = [1]
)
而不是:
date duration
1 2000-01-02 1970-01-01 00:05:00
我收到:
date duration
1 NaT NaT
是虫子吗?你知道吗
我用熊猫0.25.0
从
DataFrame
构造函数中删除Series
,因为它们的默认索引是0
,与index of DataFrame
不同,所以返回缺少的值(索引必须匹配):细节:
因此,如果需要
Series
,也需要将索引设置为1
:或删除
DataFrame
中的默认0
索引:相关问题 更多 >
编程相关推荐