小编Sha*_*aye的帖子

.corr 导致 ValueError: 无法将字符串转换为浮点数

当尝试遵循以下在 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)

python correlation pandas valueerror

13
推荐指数
2
解决办法
9414
查看次数

错误:pysqlite3 构建轮子失败

我尝试安装 pysqlite3 但出现以下错误:

\n
ERROR: 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\n
Run Code Online (Sandbox Code Playgroud)\n

我可以导入 pysqlite3 并使用它。这个错误是否重大或重大?

\n
H:\\>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)

sqlite python-3.x

6
推荐指数
0
解决办法
1804
查看次数

标签 统计

correlation ×1

pandas ×1

python ×1

python-3.x ×1

sqlite ×1

valueerror ×1