You can use the following function to calculate a weighted average in Pandas: def w_avg(df, values, weights): d = df[values] w = df[weights] return (d…
Category: Uncategorized
You can use the following syntax to sort a pandas DataFrame by both index and column: df = df.sort_values(by = [‘column_name’, ‘index’], ascending = [False,…
You can use the following syntax to quickly sort a pandas DataFrame by column names: df = df[[‘column1’, ‘column4’, ‘column3’, ‘column2’]] The following examples show…
A pairs plot is a matrix of scatterplots that lets you understand the pairwise relationship between different variables in a dataset. The easiest way to…
We can use the following formula to calculate the upper and lower bounds of a confidence interval for a population median: j: nq – z√nq(1-q)…
Pivot tables offer an easy way to summarize the values of a dataset. This tutorial provides a step-by-step example of how to create and format…
You can use the following syntax to create a pivot table using Google Sheets Query: =query(A1:C13, “select A, sum(C) group by A pivot B”) In…
You can use the following syntax to group and aggregate data in a Google Sheets Query: =query(A1:D12, “select B, avg(D) group by B”, 1) In…
You can use the following syntax to order the results of a Google Sheets Query by a certain column: =query(A1:C12, “select A, B order by…
You can use the following formula in Google Sheets to determine if a cell contains a certain string: =IF(REGEXMATCH(B1, “this”), 1, 0) In this example,…