我试图在python中查找列表中每列的中位数。这是我的代码片段 -
X_train1=np.array(X_train1).astype(np.float)
median1= X_train1.median(axis=0)
但是我收到以下错误 -
AttributeError: 'numpy.ndarray' object has no attribute 'median'
这是我的X_train1数组 -
[[ 100. 100. 100. ..., 100. 100.
100. ]
[ 91.56786232 96.62190102 98.08459941 ..., 100.4891341
99.60223361 93.26315789]
[ 92.90859973 97.64075269 103.1123983 ..., 96.08483893
99.20446722 86.42105263]
...,
[ 1193.656511 43.95921162 204.9478628 ..., 260.0710993
196.0911803 12.53894737]
[ 1199.482215 44.61122178 207.833733 ..., 266.2309527
196.7031286 12.66526316]
[ 1226.497073 44.64553811 209.5192855 ..., 267.744815
199.6481297 13.01894737]]
答案 0 :(得分:2)
你应该使用np.median。 e.g:
np.median(X_train1,axis=0)