PyCharm displays all information by default when reading Excel files, including hidden rows and columns. Workaround: Manually hide or use the Python code dropna(how='all') function to delete all rows that are completely NaN.
Why does PyCharm display all information when reading an Excel file?
When PyCharm reads an Excel file, it displays all the information in the spreadsheet by default, including hidden rows and columns. This is to ensure that you can see all the data in the workbook.
Solution:
If you only want to display visible information, you can use the following method:
Manual method:
Use Python code:
import pandas as pd # 读取 Excel 文件 df = pd.read_excel('filename.xlsx', usecols='A:D', header=0) # 显示可见数据 df = df.dropna(how='all')
Detailed instructions:
usecols
The parameter specifies that only the data in columns A to D should be read.header=0
The parameter specifies the header in line 0.dropna(how='all')
Function drops all rows that are completely NaN.Note:
The above is the detailed content of Why does pycharm display all the information when reading excel files?. For more information, please follow other related articles on the PHP Chinese website!