Python对我来说是新的,我正在使用python做一些机器学习代码.我的情况是我正在从我的sql读取数据并试图给这个数据一个形状,所以我可以用它来进行MLP训练.
我的代码如下:
connection = mysql.connector.connect(host='localhost', port=3306, user='root', passwd='mysql', db='medicalgame')
cur = connection.cursor()
query = ""
cur.execute(query)
# X_train will be a list of list and later we'll convert it to a numpy ndarray
X_train = []
for row in cur:
X_train.add(row)
connection.close()
X_train should be ready
X_train = np.asarray(X_train)
print 'The shape of X_train is', X_train.shape
Run Code Online (Sandbox Code Playgroud)
在调试期间,我得到的查询结果是这样的:(6,1,1,1,2,u'F',1,0,0,19)任何人都可以帮助我怎么做,我修复错误并给出形状我的X_train,以便MLP接受它作为输入?
我有这样的格式的日期字符串:19930508.我想从这个字符串中仅使用0508这是MMdd,而不是将它与今天的MMdd进行比较.我使用的代码是:
Date todaysDate = new Date();
String dateTest = "19930508";
SimpleDateFormat df = new SimpleDateFormat("MMdd");
Date date = df.parse(dateTest);
String birthDate = df.format(date);
if(birthDate.equals(df.format(todaysDate))){do something}
Run Code Online (Sandbox Code Playgroud)
问题是,生日形式的甲酸盐无法正常运作今天的日期.日期日期var打印没有和birthDate字符串打印0220这对我没有意义.任何人如果能够使用这种格式化并将其与今天的日期进行比较?