"pd.read_csv()" 没有重载匹配参数参数类型:(Literal['../cleaned_data.csv.zip'], Literal['zip'])
No overloads for "pd.read_csv()" match parameters Argument types: (Literal['../cleaned_data.csv.zip'], Literal['zip'])
如何修复 VS Code 的以下警告:
No overloads for "pd.read_csv(filepath_or_buffer=input_dir, compression='zip')" match parameters
Argument types: (Literal['../cleaned_data.csv.zip'], Literal['zip'])Pylance (reportGeneralTypeIssues)
求代码
cleaned_df = pd.read_csv(filepath_or_buffer = input_dir, compression = 'zip')
P.S。此错误来自 Pylance
解决方法
将 filepath_or_buffer
作为位置参数而不是关键字参数传递:
cleaned_df = pd.read_csv(input_dir, compression = 'zip')
说明
Pandas code and documentation 说第一个参数被命名为 filepath_or_buffer
但用于输入的模块存根说它被命名为 filepath
.
Pandas代码:
Pylance 存根:
如果您希望忽略该错误并等待 Pylance 的未来修复,您可以执行以下操作:
cleaned_df = pd.read_csv(filepath_or_buffer = "aaa", compression = 'zip') # type: ignore
当然忽略类型错误不是好的做法,但这是类型检查器中的错误所以..
如何修复 VS Code 的以下警告:
No overloads for "pd.read_csv(filepath_or_buffer=input_dir, compression='zip')" match parameters
Argument types: (Literal['../cleaned_data.csv.zip'], Literal['zip'])Pylance (reportGeneralTypeIssues)
求代码
cleaned_df = pd.read_csv(filepath_or_buffer = input_dir, compression = 'zip')
P.S。此错误来自 Pylance
解决方法
将 filepath_or_buffer
作为位置参数而不是关键字参数传递:
cleaned_df = pd.read_csv(input_dir, compression = 'zip')
说明
Pandas code and documentation 说第一个参数被命名为 filepath_or_buffer
但用于输入的模块存根说它被命名为 filepath
.
Pandas代码:
Pylance 存根:
如果您希望忽略该错误并等待 Pylance 的未来修复,您可以执行以下操作:
cleaned_df = pd.read_csv(filepath_or_buffer = "aaa", compression = 'zip') # type: ignore
当然忽略类型错误不是好的做法,但这是类型检查器中的错误所以..