import pandas as pd
df = pd.read_csv("data_groups.csv")
Run to view results
groups = sorted(df["grouping"].unique())
for gp in groups:
df_sub = df[df["grouping"] == gp]
print("The group is", gp) # if you know f-strings, those could be used instead
print("The mean of x is", df_sub["x"].mean(),
"The standard deviation of x is", df_sub["x"].std())
print("The mean of y is", df_sub["y"].mean(),
"The standard deviation of y is", df_sub["y"].std())
print()
Run to view results
df.groupby("grouping").mean()
Run to view results
a = df.groupby("grouping").mean()
b = df.groupby("grouping").std()
print(a)
print(b)
Run to view results
import altair as alt
import pandas as pd
chart = alt.Chart(df).mark_circle().encode(
x='x',
y='y',
color='grouping:N'
).properties(
width=600,
height=400
)
chart
Run to view results
chart = alt.Chart(df).mark_circle().encode(
x='x',
y='y',
color='grouping:N'
).facet(
row='grouping:N'
).properties(
width=600,
height=50
)
chart
Run to view results
import seaborn as sns
import matplotlib.pyplot as plt
g = sns.FacetGrid(df, col="grouping", col_wrap=4, height=3) # Adjust col_wrap and height as needed
g.map(sns.scatterplot, "x", "y")
plt.show()
Run to view results
import plotly.express as px
fig = px.scatter(df, x="x", y="y", color="grouping", facet_row="grouping")
fig.update_layout(height=4000) # Adjust the height as needed to fit the number of facets
fig.show()
Run to view results