擅长:python、mysql、java
<p>为了避免值嵌套在数组中,您可以直接使用<strong>数据帧,如下代码所示:</p>
<pre><code>import pandas as pd
from sqlalchemy import create_engine
engine = create_engine('mysql://xxxx:xxxx@localhost:3306/test')
conn = engine.connect()
lastLpnTime = pd.read_sql('SELECT MAX(timestamp) as max_time FROM
test.test_table WHERE topic = "lpn1";', conn).iloc[0]['max_time']
firstLpnTime = pd.read_sql('SELECT MIN(timestamp) as min_time FROM
test.test_table WHERE topic = "lpn1"', conn).iloc[0]['min_time']
firstLpnTime = firstLpnTime.round('20T')
firstLpnTime
</code></pre>
<p>这将在时间戳类中提供预期的输出。你知道吗</p>
<pre><code>Timestamp('2019-07-26 15:00:00')
</code></pre>
<p>希望有帮助!:)</p>