Pandas组合中的dtype丢失

2024-04-16 21:11:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我在两个系列(pandas版本0.14.1)中首次使用combine_时遇到了一个奇怪的行为。 int32和s2都是类型。得到的序列是float类型的。使用例如concat时不会发生这种情况。我在想,我是不是误会了什么或者是偶然发现了一个bug?在

我读过这篇文章,但似乎是另外一篇文章: pandas DataFrame combine_first and update methods have strange behavior

import pandas as pd
from pandas import Series

s1 = Series(range(0, 5), index=pd.date_range('20140903', periods=5, freq='d'))
s2 = Series(range(0, 5), index=pd.date_range('20140901', periods=5, freq='d'))

print s1.combine_first(s2)

Tags: import版本类型pandasdateindexrangeseries