Specify columns to aggregate and save figures as pdfs.
parent
118e686491
commit
a7446cc34a
|
@ -70,12 +70,9 @@ df_esm_PANAS_daily_means = (
|
||||||
# %%
|
# %%
|
||||||
df_esm_PANAS_summary_participant = (
|
df_esm_PANAS_summary_participant = (
|
||||||
df_esm_PANAS_daily_means.groupby(["participant_id", "questionnaire_id"])
|
df_esm_PANAS_daily_means.groupby(["participant_id", "questionnaire_id"])
|
||||||
.agg(["mean", "median", "std"])
|
.esm_numeric_mean.agg(["mean", "median", "std"])
|
||||||
.reset_index(col_level=1)
|
.reset_index(col_level=1)
|
||||||
)
|
)
|
||||||
df_esm_PANAS_summary_participant.columns = (
|
|
||||||
df_esm_PANAS_summary_participant.columns.get_level_values(1)
|
|
||||||
)
|
|
||||||
df_esm_PANAS_summary_participant[
|
df_esm_PANAS_summary_participant[
|
||||||
"PANAS_subscale"
|
"PANAS_subscale"
|
||||||
] = df_esm_PANAS_daily_means.questionnaire_id.astype("category").cat.rename_categories(
|
] = df_esm_PANAS_daily_means.questionnaire_id.astype("category").cat.rename_categories(
|
||||||
|
@ -87,7 +84,7 @@ fig1 = sns.displot(
|
||||||
data=df_esm_PANAS_summary_participant, x="mean", hue="PANAS_subscale", binwidth=0.2
|
data=df_esm_PANAS_summary_participant, x="mean", hue="PANAS_subscale", binwidth=0.2
|
||||||
)
|
)
|
||||||
if save_figs:
|
if save_figs:
|
||||||
fig1.figure.savefig("PANAS_mean_participant.png", dpi=300)
|
fig1.figure.savefig("PANAS_mean_participant.pdf", dpi=300)
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
sns.displot(
|
sns.displot(
|
||||||
|
@ -102,7 +99,7 @@ fig2 = sns.displot(
|
||||||
data=df_esm_PANAS_summary_participant, x="std", hue="PANAS_subscale", binwidth=0.05
|
data=df_esm_PANAS_summary_participant, x="std", hue="PANAS_subscale", binwidth=0.05
|
||||||
)
|
)
|
||||||
if save_figs:
|
if save_figs:
|
||||||
fig2.figure.savefig("PANAS_std_participant.png", dpi=300)
|
fig2.figure.savefig("PANAS_std_participant.pdf", dpi=300)
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
df_esm_PANAS_summary_participant[df_esm_PANAS_summary_participant["std"] < 0.1]
|
df_esm_PANAS_summary_participant[df_esm_PANAS_summary_participant["std"] < 0.1]
|
||||||
|
@ -145,17 +142,14 @@ df_esm_SAM_daily_events = (
|
||||||
# %%
|
# %%
|
||||||
df_esm_SAM_event_summary_participant = (
|
df_esm_SAM_event_summary_participant = (
|
||||||
df_esm_SAM_daily_events.groupby(["participant_id"])
|
df_esm_SAM_daily_events.groupby(["participant_id"])
|
||||||
.agg(["mean", "median", "std"])
|
.SAM_event_ratio.agg(["mean", "median", "std"])
|
||||||
.reset_index(col_level=1)
|
.reset_index(col_level=1)
|
||||||
)
|
)
|
||||||
df_esm_SAM_event_summary_participant.columns = (
|
|
||||||
df_esm_SAM_event_summary_participant.columns.get_level_values(1)
|
|
||||||
)
|
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
fig6 = sns.displot(data=df_esm_SAM_event_summary_participant, x="mean", binwidth=0.1)
|
fig6 = sns.displot(data=df_esm_SAM_event_summary_participant, x="mean", binwidth=0.1)
|
||||||
if save_figs:
|
if save_figs:
|
||||||
fig6.figure.savefig("SAM_events_mean_participant.png", dpi=300)
|
fig6.figure.savefig("SAM_events_mean_participant.pdf", dpi=300)
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
sns.displot(data=df_esm_SAM_event_summary_participant, x="std", binwidth=0.05)
|
sns.displot(data=df_esm_SAM_event_summary_participant, x="std", binwidth=0.05)
|
||||||
|
@ -190,12 +184,9 @@ df_esm_SAM_daily_threat_challenge = df_esm_SAM_daily[
|
||||||
# %%
|
# %%
|
||||||
df_esm_SAM_summary_participant = (
|
df_esm_SAM_summary_participant = (
|
||||||
df_esm_SAM_daily.groupby(["participant_id", "questionnaire_id"])
|
df_esm_SAM_daily.groupby(["participant_id", "questionnaire_id"])
|
||||||
.agg(["mean", "median", "std"])
|
.esm_numeric_mean.agg(["mean", "median", "std"])
|
||||||
.reset_index(col_level=1)
|
.reset_index(col_level=1)
|
||||||
)
|
)
|
||||||
df_esm_SAM_summary_participant.columns = (
|
|
||||||
df_esm_SAM_summary_participant.columns.get_level_values(1)
|
|
||||||
)
|
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
df_esm_SAM_threat_challenge_summary_participant = df_esm_SAM_summary_participant[
|
df_esm_SAM_threat_challenge_summary_participant = df_esm_SAM_summary_participant[
|
||||||
|
@ -226,7 +217,7 @@ fig3 = sns.displot(
|
||||||
binwidth=0.1,
|
binwidth=0.1,
|
||||||
)
|
)
|
||||||
if save_figs:
|
if save_figs:
|
||||||
fig3.figure.savefig("SAM_std_participant.png", dpi=300)
|
fig3.figure.savefig("SAM_std_participant.pdf", dpi=300)
|
||||||
|
|
||||||
# %% [markdown]
|
# %% [markdown]
|
||||||
# ## Stressfulness of period
|
# ## Stressfulness of period
|
||||||
|
@ -268,12 +259,9 @@ df_esm_JCQ_daily = (
|
||||||
)
|
)
|
||||||
df_esm_JCQ_summary_participant = (
|
df_esm_JCQ_summary_participant = (
|
||||||
df_esm_JCQ_daily.groupby(["participant_id", "questionnaire_id"])
|
df_esm_JCQ_daily.groupby(["participant_id", "questionnaire_id"])
|
||||||
.agg(["mean", "median", "std"])
|
.esm_score_mean.agg(["mean", "median", "std"])
|
||||||
.reset_index(col_level=1)
|
.reset_index(col_level=1)
|
||||||
)
|
)
|
||||||
df_esm_JCQ_summary_participant.columns = (
|
|
||||||
df_esm_JCQ_summary_participant.columns.get_level_values(1)
|
|
||||||
)
|
|
||||||
df_esm_JCQ_summary_participant[
|
df_esm_JCQ_summary_participant[
|
||||||
"JCQ_subscale"
|
"JCQ_subscale"
|
||||||
] = df_esm_JCQ_summary_participant.questionnaire_id.astype(
|
] = df_esm_JCQ_summary_participant.questionnaire_id.astype(
|
||||||
|
@ -290,7 +278,7 @@ fig4 = sns.displot(
|
||||||
binwidth=0.1,
|
binwidth=0.1,
|
||||||
)
|
)
|
||||||
if save_figs:
|
if save_figs:
|
||||||
fig4.figure.savefig("JCQ_mean_participant.png", dpi=300)
|
fig4.figure.savefig("JCQ_mean_participant.pdf", dpi=300)
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
fig5 = sns.displot(
|
fig5 = sns.displot(
|
||||||
|
@ -300,6 +288,4 @@ fig5 = sns.displot(
|
||||||
binwidth=0.05,
|
binwidth=0.05,
|
||||||
)
|
)
|
||||||
if save_figs:
|
if save_figs:
|
||||||
fig5.figure.savefig("JCQ_std_participant.png", dpi=300)
|
fig5.figure.savefig("JCQ_std_participant.pdf", dpi=300)
|
||||||
|
|
||||||
# %%
|
|
||||||
|
|
Loading…
Reference in New Issue