I learned python and pandas before SQL, so this question is a bit basic.
For example, I have a
type column with values like 1, 2, 3.
Then when I do df['type'].value_counts, I can get the statistics of the
type, maybe something like
1: 1000 rows 2: 220 rows 3: 100 rows
I want to know What is the equivalent in SQL? I believe it should be something about group_by and count?pythonsqlpandas
If you want to know how many times each value occurs in a column, use:
SELECT type, count(*) FROM table GROUP BY type
SELECT type, count(1) as num_types FROM table GROUP BY type
will return the equivalent row counts.