Here is a simple function which you can use directly by passing a dataframe and a threshold
def rmissingvaluecol(dff, threshold):
l = []
l = list(dff.drop(dff.loc[:,list((100*(dff.isnull().sum()/len(dff.index)) >= threshold))].columns, 1).columns.values)
print("# Columns having more than %s percent missing values: "%threshold, (dff.shape[1] - len(l)))
print("Columns:\n", list(set(list((dff.columns.values))) - set(l)))
return l
rmissingvaluecol(df,80) # Here threshold is 80% which means we are going to drop columns having more than 80% of missing values
# Output
'''
# Columns having more than 60 percent missing values: 2
Columns:
['id', 'location']
'''
Now create a new dataframe excluding these columns:
l = rmissingvaluecol(df, 49)
df1 = df[l]
Bonus step
You can find the percentage of missing values for each column (optional)
def missing(dff):
print (round((dff.isnull().sum() * 100/ len(dff)),2).sort_values(ascending=False))
missing(df)
# Output
'''
id 83.33
location 83.33
owner 16.67
pets 16.67
dtype: float64
'''