Spaces:
Running
Running
Update qresult.py
Browse files- qresult.py +8 -3
qresult.py
CHANGED
|
@@ -33,20 +33,25 @@ def fetch_qresult(symbol):
|
|
| 33 |
bs_t = bs.T if bs is not None else None
|
| 34 |
cf_t = cf.T if cf is not None else None
|
| 35 |
|
| 36 |
-
#
|
| 37 |
def format_df(df):
|
| 38 |
df_formatted = df.copy()
|
|
|
|
|
|
|
| 39 |
for col in df_formatted.columns:
|
| 40 |
df_formatted[col] = df_formatted[col].apply(
|
| 41 |
-
lambda x:
|
| 42 |
)
|
| 43 |
-
|
|
|
|
| 44 |
df_formatted.index = [
|
| 45 |
format_timestamp_to_date(i.timestamp()) if hasattr(i, "timestamp") else str(i)
|
| 46 |
for i in df_formatted.index
|
| 47 |
]
|
|
|
|
| 48 |
return df_formatted
|
| 49 |
|
|
|
|
| 50 |
q_html = format_df(q_t).to_html(classes="styled-table", border=0)
|
| 51 |
|
| 52 |
y_html = ""
|
|
|
|
| 33 |
bs_t = bs.T if bs is not None else None
|
| 34 |
cf_t = cf.T if cf is not None else None
|
| 35 |
|
| 36 |
+
# ------------------------
|
| 37 |
def format_df(df):
|
| 38 |
df_formatted = df.copy()
|
| 39 |
+
|
| 40 |
+
# Format numeric columns
|
| 41 |
for col in df_formatted.columns:
|
| 42 |
df_formatted[col] = df_formatted[col].apply(
|
| 43 |
+
lambda x: format_number(x) if isinstance(x, (int, float)) else x
|
| 44 |
)
|
| 45 |
+
|
| 46 |
+
# Fix index (assume index is datetime-like)
|
| 47 |
df_formatted.index = [
|
| 48 |
format_timestamp_to_date(i.timestamp()) if hasattr(i, "timestamp") else str(i)
|
| 49 |
for i in df_formatted.index
|
| 50 |
]
|
| 51 |
+
|
| 52 |
return df_formatted
|
| 53 |
|
| 54 |
+
|
| 55 |
q_html = format_df(q_t).to_html(classes="styled-table", border=0)
|
| 56 |
|
| 57 |
y_html = ""
|