Skipping errors when converting Pandas series to int8

Calling astype on #Python #Pandas series with unconvertible values? Use errors='ignore' to skip the error: s = pd.Series([10, np.nan, 30]) s.astype('int8') # raises IntCastingNaNError s.astype('int8', errors='ignore') # keeps original dtype

  • No alternative text description for this image

Reuven Lerner: so what is the goal of using "astype" it if dtype keeps the same? I didn't get it!

To view or add a comment, sign in

Explore content categories