shift converts my column from integer to float. It turns out that np.nan is float only. Is there any ways to keep shifted column as integer?
shift
np.nan
another solution starting from pandas version 0.24.0: simply provide a value for the parameter fill_value:
0.24.0
fill_value
df['b'] = df['a'].shift(1, fill_value=0)