Hi! i would like try to print a pandas dataframe after execute Mysql query
def checkstatus():
conn = MySQLdb.connect(host=dbHost, user=dbUser, passwd=dbPasswd, db=dbDb)
cursor = conn.cursor()
return cursor
def checkstatusquerytest(cursor):
cursor.execute(querycheckstatus)
rows = cursor.fetchall()
df = pd.DataFrame( [[ij for ij in i] for i in rows] )
df.rename(columns={0: 'id', 1: 'status'}, inplace=True)
#df = df.sort(['id'], ascending=[1]) --> deprecated
df = df.sort_values(by="id")
return df
But i have the next message in error.log
2018-04-10 19:41:32,115: <h1>Critical error while processing request: /check</h1>Error running WSGI application
2018-04-10 19:41:32,124: ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
2018-04-10 19:41:32,124: File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 954, in wsgi
2018-04-10 19:41:32,124: out = self._cast(self._handle(environ))
2018-04-10 19:41:32,125:
2018-04-10 19:41:32,125: File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 887, in _cast
2018-04-10 19:41:32,125: if not out:
2018-04-10 19:41:32,125:
2018-04-10 19:41:32,125: File "/home/adriezemartinez/.local/lib/python2.7/site-packages/pandas/core/generic.py", line 1121, in __nonzero__
2018-04-10 19:41:32,125: .format(self.__class__.__name__))
Bottle has issues with Pandas Dataframe?
Thanks in advance! :D