pandas.DataFrame()AttributeError:“Index”对象没有属性“\u ndarray\u值”

2024-10-01 15:32:31 发布

您现在位置:Python中文网/ 问答频道 /正文

在尝试生成列名为的空数据帧时,我刚刚开始遇到一个相当复杂的错误

import pandas as pd

pd.__version__
Out: '1.0.1'

allGeneLen = pd.DataFrame(columns = ["Sample", "geneLength"])

Traceback (most recent call last):

  File "<ipython-input-243-4783cb8742c4>", line 1, in <module>
    allGeneLen = pd.DataFrame(columns = ["Sample", "geneLength"])

  File "C:\Users\wmn262\Anaconda3\lib\site-packages\pandas\core\frame.py", line 435, in __init__
d = {'col1': [1, 2], 'col2': [3, 4]}

  File "C:\Users\wmn262\Anaconda3\lib\site-packages\pandas\core\internals\construction.py", line 228, in init_dict
    make_block(dvals_list[n], placement=[n], ndim=2)

  File "C:\Users\wmn262\Anaconda3\lib\site-packages\pandas\core\series.py", line 871, in __getitem__

  File "C:\Users\wmn262\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 4405, in get_value
    The other object to compare against.

  File "pandas\_libs\properties.pyx", line 34, in pandas._libs.properties.CachedProperty.__get__

  File "C:\Users\wmn262\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 608, in _engine
    The array interface, return my values.

AttributeError: 'Index' object has no attribute '_ndarray_values'

我不知道为什么会发生这种情况,据我所知,这种情况不应该发生。 有人有什么见解吗


Tags: inpycoredataframepandaslibpackagesline

热门问题