Skip to content

Commit

Permalink
Hotfix for factor analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
jvivian committed Jun 14, 2024
1 parent 58907a1 commit f099d00
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions covid19_drdfm/streamlit/pages/1_Factor_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,27 @@ def get_factors(res_dir):
df = df[df["State"] == state]
df = df[[factor]].join(new, on="Time")

# st.write(factor_map)
# st.dataframe(df.head())
# st.dataframe(new.head())

# Coerce time bullshit to get dates standardized
# df["Time"] = pd.to_datetime(df["Time"]).dt.date
# new["Time"] = pd.to_datetime(new["Time"]).dt.date
col_opts = [x for x in df.columns.to_list() if x != "State"]
cols = st.multiselect("Variables to plot", col_opts, default=col_opts)
with st.expander("Graph Data"):
factor_cols = factor_map[factor_map["factor"] == factor]
if factor_cols.empty:
factor_cols = new.columns
else:
factor_cols = factor_cols.index.to_list()
factor_cols += [factor]
factor_cols = [x for x in factor_cols if x in df.columns]
st.write(factor_cols)
st.dataframe(df[factor_cols])

df = df[factor_cols].reset_index()
# factor_cols = factor_map[factor_map["factor"] == factor]
# if factor_cols.empty:
# factor_cols = new.columns
# else:
# factor_cols = factor_cols.index.to_list()
# factor_cols += [factor]
# factor_cols = [x for x in factor_cols if x in df.columns]
# st.write(factor_cols)
st.dataframe(df[cols])

df = df[cols].reset_index()

# Melt into format for plotting
# melted_df = df.drop(columns="State").melt(id_vars=["Time"], value_name="value")
Expand Down

0 comments on commit f099d00

Please sign in to comment.