成功解决ValueError: Shape of passed values is (33, 1), indices imply (33, 2)

简介: 成功解决ValueError: Shape of passed values is (33, 1), indices imply (33, 2)

解决问题


ValueError: Shape of passed values is (33, 1), indices imply (33, 2)







解决思路


值误差:传递值的形状为(33,1),索引表示为(33,2)






解决方法


在pandas中,当进行输出的时候,索引是不会成为一个单独的列的,它只是为了显示,而非实际上的dataframe内的数据,如果需要将索引一并输出,则需要另保存,然后重新读取的时候,指定索引为dataframe内的数据,大多数情况下它是默认的!


from DataScience.DataAnalysis import df_dtypes2Dict

df_dtypes=df_dtypes2Dict(df)


哈哈,大功告成!


 


相关文章
|
3月前
|
数据处理 开发者 Python
【Python】已解决:ValueError: Length mismatch: Expected axis has 5 elements, new values have 4 elements
【Python】已解决:ValueError: Length mismatch: Expected axis has 5 elements, new values have 4 elements
110 9
|
5月前
|
Linux Windows
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
|
5月前
|
Python
完美解决丨2. `TypeError: list indices must be integers or slices, not str`
完美解决丨2. `TypeError: list indices must be integers or slices, not str`
报错 ValueError: too many values to unpack (expected 2)
报错 ValueError: too many values to unpack (expected 2)
193 0
ValueError: not enough values to unpack (expected 3, got 2)
这个错误通常是因为在解包(unpacking)元组(tuple)时,元组中的元素数量与期望不符,导致无法将所有元素正确解包。 例如,在以下代码中,元组中只有两个元素,但我们尝试将其解包为三个变量:
557 0
|
机器学习/深度学习 PyTorch 算法框架/工具
解决Pytorch中RuntimeError: expected scalar type Double but found Float
解决Pytorch中RuntimeError: expected scalar type Double but found Float
2636 0
|
Python
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
619 0
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
|
Linux Python
ValueError: empty range for randrange() (0, 0, 0)
ValueError: empty range for randrange() (0, 0, 0)
|
存储 索引
成功解决ValueError: If using all scalar values, you must pass an index
成功解决ValueError: If using all scalar values, you must pass an index