【发布时间】:2021-09-01 15:51:21
【问题描述】:
我在 python 中使用 pandasql,我是 SQL 的新手
query = '''
select row_number() over (order by cumSum) as SegmentOrder
, min(rowLoc) as SegmentStart
, max(rowLoc) - min(rowLoc) as Height
from df_lineLocations
where line = 0
--and CumSum !=0
group by cumSum
'''
df_SegmentLocations = ps.sqldf(query, locals())
df_SegmentLocations
我尝试删除 row_number() 中的括号,但没有任何反应
【问题讨论】:
-
能否添加运行时打印到控制台的错误的完整回溯。
-
PandaSQLException: (sqlite3.OperationalError) near "(": 语法错误 [SQL: select row_number over (order by cumSum) as SegmentOrder , min(rowLoc) as SegmentStart , max(rowLoc) - min( rowLoc) as Height from df_lineLocations where line = 0 --and CumSum !=0 group by cumSum ](此错误的背景:sqlalche.me/e/14/e3q8)
-
@BarbarosÖzhan 我把 ''' 改成了 """ 但什么也没发生
标签: python sql sqlite sqlalchemy