I have a dataframe which has 2 columns, one is an id and another one is a string column. I want to group by the id and group_concat the string column but I am getting error:
qer = """SELECT ClaimID,group_concat(DiagnosisCodesseparator ',') asDiagnosisCodes` FROM headed GROUP BY ClaimID"""
queried = ps.sqldf(qer, locals())
Traceback (most recent call last):
File "", line 2, in
queried = ps.sqldf(qer, locals())
File "C:\ProgramData\Anaconda3\lib\site-packages\pandasql\sqldf.py", line 156, in sqldf
return PandaSQL(db_uri)(query, env)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandasql\sqldf.py", line 63, in call
raise PandaSQLException(ex)
PandaSQLException: (sqlite3.OperationalError) near "separator": syntax error [SQL: "SELECT ClaimID,group_concat(DiagnosisCodes separator ',') as DiagnosisCodes FROM headed GROUP BY ClaimID"] (Background on this error at: http://sqlalche.me/e/e3q8)`
I tested the query in mysql and it's working there and when I remove the group_concat part, it's working in python as well.
Any solution to this issue is very welcome.
I have a dataframe which has 2 columns, one is an id and another one is a string column. I want to group by the id and group_concat the string column but I am getting error:
qer = """SELECT ClaimID,group_concat(
DiagnosisCodesseparator ',') as
DiagnosisCodes` FROM headed GROUP BY ClaimID""" queried = ps.sqldf(qer, locals()) Traceback (most recent call last):File "", line 2, in
queried = ps.sqldf(qer, locals())
File "C:\ProgramData\Anaconda3\lib\site-packages\pandasql\sqldf.py", line 156, in sqldf return PandaSQL(db_uri)(query, env)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandasql\sqldf.py", line 63, in call raise PandaSQLException(ex)
PandaSQLException: (sqlite3.OperationalError) near "separator": syntax error [SQL: "SELECT ClaimID,group_concat(
DiagnosisCodes
separator ',') asDiagnosisCodes
FROM headed GROUP BY ClaimID"] (Background on this error at: http://sqlalche.me/e/e3q8)` I tested the query in mysql and it's working there and when I remove the group_concat part, it's working in python as well. Any solution to this issue is very welcome.