Skip to content
Advertisement

Convert SQL commands to Python

I have the following code in SQL:

I’ve been trying to rewrite it in python like so:

but I keep getting a generic error message. What am I doing wrong?

EDIT: added the error message

Advertisement

Answer

IIUC, you could try the following:

The equivalent of SELECT DISTINCT col is drop_duplicates(col) and the equivalent of SELECT col, count(*) is value_counts(col).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement