Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有熊猫系列之类的s = pd.Series({1: 10, 2:11, 4:5, 7:10})
s = pd.Series({1: 10, 2:11, 4:5, 7:10})
1 10 2 11 4 5 7 10 dtype: int64
我想重新采样这个系列以获得这样的系列
1 10 2 11 3 0 4 5 5 0 6 0 7 10 dtype: int64
如果您从另一个程序/代码的另一部分获得您的系列,您可以尝试:
max_range = max(s.index) + 1 s = s.reindex(index=range(1, max_range), fill_value=0)