Instead of retrospectively modifying the labels, you should change directly the formatter function:
from matplotlib import pyplot as plt
import matplotlib.ticker as tkr
def numfmt(x, pos):
s = f'{x/1000:,.0f}' #<----
return s
yfmt = tkr.FuncFormatter(numfmt)
#sample data
import pandas as pd
df = pd.DataFrame({"cat": list("ABCDE"), "xaxis": [1, 3, 4, 5, 9], "yaxis": [1236, 3213, 2123, 6243, 1432]})
fig, ax = plt.subplots()
ax.plot(df.xaxis, df.yaxis)
ax.yaxis.set_major_formatter(yfmt)
plt.show()
Sample output:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…