python - Resampling Pandas Series with integer index (add missing index) -


i have pandas series s = pd.series({1: 10, 2:11, 4:5, 7:10})

1    10 2    11 4     5 7    10 dtype: int64 

i resample serie in order serie that

1    10 2    11 3     0 4     5 5     0 6     0 7    10 dtype: int64 

if got serie programm/another part of code, try:

max_range = max(s.index) + 1 s = s.reindex(index=range(1, max_range), fill_value=0) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -