df.isnull().any().any()
Category / Python
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
Pandas remove rows with all zeros
For Pandas dataframes, remove rows with all 0s, also applies to remove other values.
Below lines all work.
df.loc[~(df==0).all(axis=1)]
df.loc[(df!=0).any(axis=1)]
df.loc[(df!=0).any(1)]
Source: https://stackoverflow.com/questions/22649693/drop-rows-with-all-zeros-in-pandas-data-frame
Merge, join, concatenate in Pandas
Concatenate two dataframes by index without sorting:
df3 = pd.concat([df1, df2], axis=1, sort=False)
The source is pretty good, I will add more clear details later.
Source: https://pandas.pydata.org/pandas-docs/stable/user_guide/merging.html
Passing Unix array to python
Unix syntax:
echo ${readIn_list[@]}
echo $var
python yourPython.py $var ${readIn_list[@]}
Python syntax:
readIn_list = sys.argv[2:]
Source: https://unix.stackexchange.com/questions/519625/passing-bash-array-to-python-script