Horje
filter all columns in pandas Code Example
filter all columns in pandas
In[1]:
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.rand(10,5))  
corr = df.corr()
corr.shape

Out[1]: (5, 5)
  
###################  

In [2]: corr_triu = corr.where(~np.tril(np.ones(corr.shape)).astype(np.bool))
         corr_triu
Out[2]: 
    0         1         2         3         4
0 NaN  0.228763 -0.276406  0.286771 -0.050825
1 NaN       NaN -0.562459 -0.596057  0.540656
2 NaN       NaN       NaN  0.402752  0.042400
3 NaN       NaN       NaN       NaN -0.642285
4 NaN       NaN       NaN       NaN       NaN

##################

In [3]: corr_triu = corr_triu.stack()
        corr_triu[corr_triu > 0.3]
Out[3]: 
1  4    0.540656
2  3    0.402752
dtype: float64




Python

Related
find poser hair Code Example find poser hair Code Example
How to colour a specific cell in pandas dataframe Code Example How to colour a specific cell in pandas dataframe Code Example
python print value and variable name Code Example python print value and variable name Code Example
generate a random np image array with shape Code Example generate a random np image array with shape Code Example
The DTypes <class 'numpy.dtype[datetime64]'> and <class 'numpy.dtype[int64]'> do not have a common DType. For example they cannot be stored in a single array unless the dtype is `object`. Cod The DTypes <class 'numpy.dtype[datetime64]'> and <class 'numpy.dtype[int64]'> do not have a common DType. For example they cannot be stored in a single array unless the dtype is `object`. Cod

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8