ValueError:索引必须是单调递增或递减 [Jupyter笔记本图片] [1]
我正在练习 python书中的上述代码片段,以供Wes McKinney进行数据分析
我这样创建一个DataFrame
frame=DataFrame(np.arange(9).reshape((3,3)), index=['a','c','d'], columns=['Ohio','Texas','California'])
当我尝试像这样重新索引它时:
states=['Texas','Utah','California']
frame.reindex(index=['a','b','c','d'],method='ffill', columns=states)
为什么会引发ValueError?
答案 0 :(得分:1)
你可以使用
extension SKAction {
static func diagonalRotate(duration: TimeInterval) -> SKAction {
return SKAction.customAction(withDuration: duration) {
node, elapsedTime in
if let node = node as? SKTransformNode {
// should be Float.pi to do half a revolution,
// but the problem starts to occur nearby 0.667 * CGFloat.pi
let angle = 0.667 * Float.pi * (Float(elapsedTime) / Float(duration))
let c = cos(angle)
let s = sin(angle)
let xRot = matrix_float3x3([[1, 0, 0],
[0, c, -s],
[0, s, c]])
let yRot = matrix_float3x3([[c, 0, s],
[0, 1, 0],
[-s, 0, c]])
// matrix for diagonal rotation where South East becomes North West
dRot = (xRot + yRot) * 0.5
print("angle: \(angle)\tcos: \(c)\tsin: \(s)")
print("dRot matrix: \(dRot)")
node.setRotationMatrix(dRot)
print("node matrix: \(node.rotationMatrix())")
}
}
}
}