import pandas as pd
# create a sample DataFrame
df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]})
# define a custom function that replaces the diagonal of a row with zeros
def zero_diagonal(row):
for i in range(len(row)):
row[i] = 0 if i == row.name or i == len(row) - row.name - 1 else row[i]
return row
# apply the custom function to each row of the DataFrame
df = df.apply(zero_diagonal, axis=1)
df