awacke1 commited on
Commit
68c84b8
ยท
1 Parent(s): 0e81c8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -76,11 +76,25 @@ plot_tokens(history["health_tokens"], history["coin_tokens"])
76
  timestamp = datetime.now().strftime("%m-%d-%Y-%H-%M-%S")
77
  filename = f"{timestamp}.csv"
78
  data = {"Username": [username], "Date": [timestamp], **history}
79
- df = pd.DataFrame(data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  df.to_csv(filename, index=False)
81
 
82
  # Show download link for CSV file
83
  st.write("Download the dice rolling history:")
84
  with open(filename, "rb") as f:
85
  bytes_data = f.read()
86
-
 
76
  timestamp = datetime.now().strftime("%m-%d-%Y-%H-%M-%S")
77
  filename = f"{timestamp}.csv"
78
  data = {"Username": [username], "Date": [timestamp], **history}
79
+
80
+ # Concatenate all roll histories into a single dictionary
81
+ all_rolls = {}
82
+ for dice_type, rolls in history["roll_history"].items():
83
+ all_rolls[f"{dice_type}-sided dice"] = rolls
84
+ all_rolls = pd.DataFrame(all_rolls)
85
+
86
+ # Create a Series for each token type
87
+ health_tokens = pd.Series(history["health_tokens"], name="Health Tokens")
88
+ coin_tokens = pd.Series(history["coin_tokens"], name="Coin Tokens")
89
+
90
+ # Concatenate all data into a single DataFrame
91
+ df = pd.concat([all_rolls, health_tokens, coin_tokens], axis=1)
92
+
93
+ # Save history to CSV file
94
  df.to_csv(filename, index=False)
95
 
96
  # Show download link for CSV file
97
  st.write("Download the dice rolling history:")
98
  with open(filename, "rb") as f:
99
  bytes_data = f.read()
100
+