当尝试遵循以下在 Python 中使用 corr() 方法的练习时,我遇到了这个非常奇怪的错误
https://www.geeksforgeeks.org/python-pandas-dataframe-corr/
具体来说,当我尝试运行以下代码时:df.corr(method ='pearson')
错误消息没有提供任何线索。我认为 corr() 方法应该自动忽略字符串和空值等。
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
df.corr(method='pearson')
File "C:\Users\d.o\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\frame.py", line 10059, in corr
mat = data.to_numpy(dtype=float, na_value=np.nan, copy=False)
File "C:\Users\d.o\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\frame.py", line 1838, in to_numpy
result = self._mgr.as_array(dtype=dtype, copy=copy, na_value=na_value)
File "C:\Users\d.o\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\internals\managers.py", line 1732, in as_array
arr = self._interleave(dtype=dtype, na_value=na_value)
File "C:\Users\d.o\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\internals\managers.py", line 1794, in _interleave
result[rl.indexer] = arr
ValueError: could not convert string to float: 'Avery Bradley'
Run Code Online (Sandbox Code Playgroud) 我尝试安装 pysqlite3 但出现以下错误:
\nERROR: Failed building wheel for pysqlite3;\nFailed to build pysqlite3;\nERROR: Could not build wheels for pysqlite3, which is required to install pyproject.toml-based projects\nRun Code Online (Sandbox Code Playgroud)\n我可以导入 pysqlite3 并使用它。这个错误是否重大或重大?
\nH:\\>python -m pip install pysqlite3\nCollecting pysqlite3\n Using cached pysqlite3-0.5.0.tar.gz (40 kB)\n Preparing metadata (setup.py) ... done\nBuilding wheels for collected packages: pysqlite3\n Building wheel for pysqlite3 (setup.py) ... error\n error: subprocess-exited-with-error\n\n \xc3\x97 python setup.py bdist_wheel did not run successfully.\n \xe2\x94\x82 exit code: 1\n \xe2\x95\xb0\xe2\x94\x80> [18 lines of output]\n running bdist_wheel\n …Run Code Online (Sandbox Code Playgroud)