Skip to content

Tag: python

pandas: Convert string column to ordered Category?

I’m working with pandas for the first time. I have a column with survey responses in, which can take ‘strongly agree’, ‘agree’, ‘disagree’, ‘strongly disagree’, and ‘neither’ values. This is the output of describe() and value_counts() for the c…

Object Oriented Python with Flask Server?

I’m using Flask to expose some data-crunching code as a web service. I’d like to have some class variables that my Flask functions can access. Let me walk you through where I’m stuck: When I run getSomeData() outside of Flask, it works fine. But, when I run this with Flask, I get 500 interna…

ImportError: No module named ‘Tkinter’

For some reason, I can’t use the Tkinter or tkinter module. After running the following command in the python shell or I got this error ModuleNotFoundError: No module named ‘Tkinter’ or ModuleNotFoundError: No module named ‘tkinter’ What could be the reason for and how can we sol…

Installing psycopg2 in a virtualenv in ubuntu os

I using a virtualenv and I am trying to set up postgresql. I have psycopg2 installed on my system, but it appears that my virtual env does not recognize psycopg2. Is it possible to just copy the system wide psycopg2 files into my django project directory or is this a bad approach to take? This is the relevant…

Function sequence error in PYODBC

I am using pyodbc to connect to a database and extract certain data from it. Here is my code: And I got following error after I run above code: pyodbc.Error: (‘HY010’, ‘[HY010] [Microsoft][ODBC SQL Server Driver]Function sequence error (0) (SQLFetch)’) May I know what caused such probl…