如何打印在读取 pandas 数据框期间显示警告的文档名称

How to print the name of document that during the reading to pandas data frame displays the warning

我在读取 excel 文档到数据框的过程中收到此警告:

*

Warning (from warnings module):
  File "C:\Users\Slobo\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\frame.py", line 6211
    sort=sort)
FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.
To accept the future behavior, pass 'sort=False'.
To retain the current behavior and silence the warning, pass 'sort=True'.

*

为了读取特定文件夹中的所有文档,我使用了这个:

`for f in glob.glob(dirname + "/*.xlsx")`:
    #where dirname is the path to the folder, and then for reading documents:
    pd.read_excel(f)

我想打印在读取数据框时出现警告的文档的名称。

怎么做?

import warnings
warnings.filterwarnings("error")

for f in glob.glob(dirname + "/*.xlsx"):
    try:
       pd.read_excel(f)
    except Warning as w:
        print(f)