SELECT *, iif(Sector por Causal is null or Sector por Causal like '', "Petición",…
- User
SELECT *, iif(Sector por Causal is null or Sector por Causal like '', "Petición", IIF(Sector por Causal like '%sector%',"Sin Sector", IIF(Sector por Causal like '%Petici%',"Petición", IIF(Sector por Causal like '%Queja%',"Queja", iif(Sector por Causal like '%Recla%',"Reclamo", iif(Sector por Causal like '%Entidad%',"Entidades", IIF(Sector por Causal like '%inform%',"Información_Publica", iif(Sector por Causal like '%suger%',"Sugerencia", iif(Sector por Causal like '%traslado%',"Traslado_por_competencia", "Petición")))))))) AS 'Sector' FROM archivo': near "por": syntax error
- Assistant
It seems like there is a syntax error in the query. The error is occurring near the word "por".
To fix the error, remove the colon (':') after "archivo" and place it after the closing quotation mark of the alias 'Sector'.
Here's the corrected query:
SELECT *, iif(Sector_por_Causal is null or Sector_por_Causal like '', "Petición", IIF(Sector_por_Causal like '%sector%',"Sin Sector", IIF(Sector_por_Causal like '%Petici%',"Petición", IIF(Sector_por_Causal like '%Queja%',"Queja", iif(Sector_por_Causal like '%Recla%',"Reclamo", iif(Sector_por_Causal like '%Entidad%',"Entidades", IIF(Sector_por_Causal like '%inform%',"Información_Pública", iif(Sector_por_Causal like '%suger%',"Sugerencia", iif(Sector_por_Causal like '%traslado%',"Traslado_por_competencia", "Petición")))))))) AS 'Sector' FROM archivo
- User
como quitarle el espacio a la columna sector por causal en python
- Assistant
To remove spaces from the 'Sector por Causal' column in Python, you can use the str.replace() method. Here's an example:
pythonimport pandas as pd # Read the data into a DataFrame df = pd.read_csv('archivo.csv') # Remove spaces from the 'Sector por Causal' column df['Sector por Causal'] = df['Sector por Causal'].str.replace(' ', '') # Print the modified DataFrame print(df)In this example, we use the pandas library to read the data from a CSV file and store it in a DataFrame called 'df'. Then, we use the str.replace() method to remove spaces from the 'Sector por Causal' column. Finally, we print the modified DataFrame.
- User
DatabaseError: Execution failed on sql ' SELECT *, iif(Sector_por_Causal is null or Sector_por_Causal like '', "Petición", IIF(Sector_por_Causal like '%sector%',"Sin Sector", IIF(Sector_por_Causal like '%Petici%',"Petición", IIF(Sector_por_Causal like '%Queja%',"Queja", iif(Sector_por_Causal like '%Recla%',"Reclamo", iif(Sector_por_Causal like '%Entidad%',"Entidades", IIF(Sector_por_Causal like '%inform%',"Información_Publica", iif(Sector_por_Causal like '%suger%',"Sugerencia", iif(Sector_por_Causal like '%traslado%',"Traslado_por_competencia", "Petición")))))))) AS 'Sector' FROM archivo': near "AS": syntax error
- Assistant
Apologies for the confusion in my previous response. It seems that the query is being executed on a database, and the error is due to incorrect syntax.
Here's the updated query with the corrected syntax:
pythonSELECT *, CASE WHEN Sector_por_Causal IS NULL OR Sector_por_Causal = '' THEN 'Petición' WHEN Sector_por_Causal LIKE '%sector%' THEN 'Sin Sector' WHEN Sector_por_Causal LIKE '%Petici%' THEN 'Petición' WHEN Sector_por_Causal LIKE '%Queja%' THEN 'Queja' WHEN Sector_por_Causal LIKE '%Recla%' THEN 'Reclamo' WHEN Sector_por_Causal LIKE '%Entidad%' THEN 'Entidades' WHEN Sector_por_Causal LIKE '%inform%' THEN 'Información_Publica' WHEN Sector_por_Causal LIKE '%suger%' THEN 'Sugerencia' WHEN Sector_por_Causal LIKE '%traslado%' THEN 'Traslado_por_competencia' ELSE 'Petición' END AS Sector FROM archivo