成功解决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)


哈哈,大功告成!


 


相关文章
|
14天前
|
TensorFlow 算法框架/工具 Python
RuntimeError: Given groups=1, weight of size 64 128 1 7, expected input[16,
RuntimeError: Given groups=1, weight of size 64 128 1 7, expected input[16,
3008 0
|
6月前
|
数据处理 开发者 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
461 9
报错 ValueError: too many values to unpack (expected 2)
报错 ValueError: too many values to unpack (expected 2)
226 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
660 0
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
ValueError: not enough values to unpack (expected 3, got 2)
这个错误通常是因为在解包(unpacking)元组(tuple)时,元组中的元素数量与期望不符,导致无法将所有元素正确解包。 例如,在以下代码中,元组中只有两个元素,但我们尝试将其解包为三个变量:
672 0
|
TensorFlow 算法框架/工具
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘
293 0
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘
|
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