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

Convert the string 2.90K to 2900 or 5.2M to 5200000 in pandas dataframe

def value_to_float(x): if type(x) == float or type(x) == int: return x if ‘K’ in x: if len(x) > 1: return float(x.replace(‘K’, ”)) * 1000 return 1000.0 if ‘M’ in x: if len(x) > 1: return float(x.replace(‘M’, ”)) * 1000000 return 1000000.0 if ‘B’ in x: return float(x.replace(‘B’, ”)) * 1000000000 return 0.0 df[‘col’] = … Read more

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.