drop trailing zeros from decimal

Question or problem about Python programming: I have a long list of Decimals and that I have to adjust by factors of 10, 100, 1000,….. 1000000 depending on certain conditions. When I multiply them there is sometimes a useless trailing zero (though not always) that I want to get rid of. For example…

Continue Reading

pandas equivalent of np.where

Question or problem about Python programming: np.where has the semantics of a vectorized if/else (similar to Apache Spark’s when/otherwise DataFrame method). I know that I can use np.where on pandas Series, but pandas often defines its own API to use instead of raw numpy functions, which is usually more convenient with pd.Series/pd.DataFrame.

Continue Reading