1
對於分析,有時更好地訪問選擇結果的列而不是行。比方說,我們要繪製一個特定的記錄點的電壓軌跡(RP)和數據存儲在表* 錄音 *這樣有沒有一種優雅的方式來訪問表「列」,而不是使用sqlalchemy的行?
__________________________________
|rp_key | time | value_mV |
----------------------------------
| 1 | 1 | -65 |
----------------------------------
| 1 | 2 | -64.4 |
----------------------------------
| 1 | 3 | -65.3 |
----------------------------------
| 2 | 1 | -67.9 |
----------------------------------
| 2 | 2 | -68.0 |
----------------------------------
現在我想繪製這樣的:
import sqlalchemy as sa
import matplotlib.pyplot as plt
# ...
res = session.query(Recording).filter_by(rp_key=1).all()
# HERE: elegant sqlalchemy-way of accessing the columns of the result
plt.plot(time, value_mV)
你會提出什麼建議?