Real IT problem solving

What is often missing from PowerPoint presentations and other possibily usefull notes

Real IT problem solving Uncategorized Python dataframes selection for people with SQL background

Python dataframes selection for people with SQL background

SELECT column_name FROM data_frame

df[[‘column_name’]]

SELECT column_name FROM data_frame LIMIT 10

df[[‘column_name’]].head(10)

SELECT * FROM data_frame WHERE column_name = ‘value’

df[(df[‘column_name’] == ‘value’)]

SELECT column_name FROM data_frame WHERE co1_name = ‘value2’ AND col2_name = ‘value2’

df[[‘column_name’]][(df[‘col1_name’] == ‘value1’) & (df[‘col2_name’] == ‘value2’)].head(100)

SELECT date_part, count(*) FROM data_frame GROUP BY date_part – for dataframes with DatetimeIndex

To count column “column_name” by weeks (W)

df.resample(‘W’).agg({“column_name”:’size’})

SELECT date_part, count(*) FROM data_frame WHERE column_name = ‘col_value’ GROUP BY date_part ORDER BY count(*) DESC LIMIT 10 – for dataframes with DatetimeIndex

To count column “column_name” by minutes (1T)

df[(df[‘column_name’] == ‘col_value’)].resample(‘1T’).agg({“column_name”:’size’}).sort_values(by=’column_name’, ascending=False).head(10)

Leave a Reply to DamianBen Cancel reply

Your email address will not be published. Required fields are marked *

TopBack to Top