Horje
How to replace both the diagonals of dataframe with 0 in pandas Code Example
How to replace both the diagonals of dataframe with 0 in pandas
import pandas as pd 
import numpy as np

df = pd.DataFrame(np.random.randint(1,100, 100).reshape(10, -1))

out = df.where(df.values != np.diag(df),0,df.where(df.values != np.flipud(df).diagonal(0),0,inplace=True))




Python

Related
remove idx of list python Code Example remove idx of list python Code Example
python cv2 get image shape Code Example python cv2 get image shape Code Example
python strip newline from string Code Example python strip newline from string Code Example
remove n from string python Code Example remove n from string python Code Example
application of stack python Code Example application of stack python Code Example

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