pandasql

AttributeError: 'str' object has no attribute '_execute_on_connection'

AttributeError: 'str' object has no attribute '_execute_on_connection' Question: I have a problem with following code: from pandasql import sqldf import pandas as pd df = pd.DataFrame({‘column1’: [1, 2, 3], ‘column2’: [4, 5, 6]}) query = "SELECT * FROM df WHERE column1 > 1" new_dataframe = sqldf(query) print(new_dataframe) When I submit, I have this error: Traceback …

Total answers: 2

Making a row_number column in a query for a combination of columns

Making a row_number column in a query for a combination of columns Question: I´m using pandasql library in Python to make an special query of DataFrames, I trying to make a new row number column from the combination of some columns. I have the next example: tabla_1= pd.DataFrame([‘a’,’b’,’c’],columns=[‘letras’]) tabla_2= pd.DataFrame([1,2],columns=[‘numeros’]) tabla_3= pd.DataFrame([‘rojo’,’verde’],columns=[‘colores’]) pysqldf = lambda …

Total answers: 1

Python Pandas to_sql, how to create a table with a primary key?

Python Pandas to_sql, how to create a table with a primary key? Question: I would like to create a MySQL table with Pandas’ to_sql function which has a primary key (it is usually kind of good to have a primary key in a mysql table) as so: group_export.to_sql(con = db, name = config.table_group_export, if_exists = …

Total answers: 5