coordinates = np.empty([0,5])
np.vstack( (coordinates, np.array([1, 2, 3, 4, 5]) ))
print coordinates # []
np.append(coordinates, np.array([1, 2, 3, 4, 5]), axis=0)
print coordinates
在上面显示的代码中,我尝试追加数组,但两种方法都失败了。在第一种方法中,输出仍然是空的,在第二种方法中,输出是一个错误说
ValueError:所有输入数组必须具有相同的维数
我的方法有什么问题?
答案 0 :(得分:0)
您需要捕获coordinates = np.empty([0, 5])
x = np.vstack((coordinates, np.array([1, 2, 3, 4, 5])))
print x
来自(Docs)
numpy.vstack(arrays,axis = 0)
返回:
stacked:ndarray
[[ 1. 2. 3. 4. 5.]]
public ArrayList<PersoaneJSON> jsonRetr (String numeRepo) throws SQLException {
String sql = "SELECT * FROM " + numeRepo;
PreparedStatement prStm = (PreparedStatement) conn.prepareStatement(sql);
ResultSet rs = prStm.executeQuery(sql);
ArrayList<PersoaneJSON> persoane = new ArrayList<PersoaneJSON>();
while (rs.next()) {
String id = rs.getString("id");
String login_name = rs.getString("login_name");
String email = rs.getString("email");
String public_gits = rs.getString("public_gits");
String Html_profile = rs.getString("Html_profile");
String Avatar_URL = rs.getString("Avatar_URL");
PersoaneJSON persoana = new PersoaneJSON(id, login_name, email, public_gits, Html_profile, Avatar_URL);
persoane.add(persoana);
}
return persoane;
}