![](/img/trans.png)
[英]IndexError: too many indices for array. Numpy array with 42 features not homogeneous
[英]IndexError: too many indices for array. Numpy + Pandas DataFrame
我希望DataFrame以'Excel'类型的方式输出,但是会得到索引错误:
'IndexError:数组的索引过多'
import numpy as np
import pandas as pd
from numpy.random import randn
rowi = ['A', 'B', 'C', 'D', 'E']
coli = ['W', 'X', 'Y', 'Z']
df = pd.DataFrame(randn[5, 4], rowi, coli) # data , index , col
print(df)
我该如何解决这个问题?
这是你想要的吗:
df = pd.DataFrame(randn(5, 4), rowi, coli)
Out[583]:
W X Y Z
A -0.630006 -0.033165 -1.005409 -0.827504
B 0.044278 0.526636 1.082062 -1.664397
C 0.523847 -0.688798 -0.626712 0.149128
D 0.541975 -1.448316 -0.961484 -0.526547
E 0.066888 0.238089 1.180641 0.462298
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.