NaN values when new column added to pandas DataFrame

Because the indexes are not exactly equal, NaNs will result. Either one or both of the indexes must be changed to match. Example: mydata = mydata.set_index(DWDATA.index) The above will change the index of the ‘mydata’ DataFrame to match the index of the ‘DWDATA’ DataFrame. Since the number of rows are exactly equal for the two … Read more

Negative NaN is not a NaN?

This is embarrassing. The reason the compiler (GCC in this case) was optimising away the comparison and isnan returned false was because someone in my team had turned on -ffast-math. From the docs: -ffast-math Sets -fno-math-errno, -funsafe-math-optimizations, -fno-trapping-math, -ffinite-math-only, -fno-rounding-math, -fno-signaling-nans and fcx-limited-range. This option causes the preprocessor macro __FAST_MATH__ to be defined. This option … Read more

How to drop column according to NAN percentage for dataframe?

You can use isnull with mean for threshold and then remove columns by boolean indexing with loc (because remove columns), also need invert condition – so <.8 means remove all columns >=0.8: df = df.loc[:, df.isnull().mean() < .8] Sample: np.random.seed(100) df = pd.DataFrame(np.random.random((100,5)), columns=list(‘ABCDE’)) df.loc[:80, ‘A’] = np.nan df.loc[:5, ‘C’] = np.nan df.loc[20:, ‘D’] = … Read more

Double.IsNaN test 100 times faster?

It claims to be 100 times faster than System.Double.IsNaN Yes, that used to be true. You are missing the time-machine to know when this decision was made. Double.IsNaN() didn’t used to look like that. From the SSCLI10 source code: public static bool IsNaN(double d) { // Comparisions of a NaN with another number is always … Read more

Equality with Double.NaN

Perhaps you are looking for the IsNaN static function? Try something like this: if (!Double.IsNaN(Price_Foreign)) { output.Append(spacer); output.Append(String.Format(“{0,-10:C} USD”,Price_Foreign)); }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)