Pandas remove rows or columns with null/nan/missing values

Remove rows with nan/null/missing values:

df = df.dropna(axis=0, how='any') # Remove if any value is na
df = df.dropna(axis=0, how='all') # Remove if all values are na

Remove columns with nan/null/missing values:

df = df.dropna(axis=1, how='any') # Remove if any value is na
df = df.dropna(axis=1, how='all') # Remove if all values are na

Defaut remove is inplace=False, if you want to remove inplace, add inplace=True

Source:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.dropna.html

Pandas apply function to values in a DataFrame

Apply your function to all values in a dataframe:

df = df+1
df = df.apply(np.sqrt)
df = df.apply(lambda x: np.log2(x+1))
df = df.apply(lambda x: function(x))

Apply function to a column or a row of the dataframe:

df.loc[:,'yourLabel'] = df.loc[:,'yourLabel'].map(lambda x: function(x))
df.loc['yourLabel',:] = df.loc['yourLabel',:].map(lambda x: function(x))

df.loc[:,'yourLabel'] = df.loc[:,'yourLabel'].apply(lambda x: function(x))
df.loc['yourLabel',:] = df.loc['yourLabel',:].apply(lambda x: function(x))

Source:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.apply.html;
https://stackoverflow.com/questions/34962104/pandas-how-can-i-use-the-apply-function-for-a-single-column