From 813fb818cd979ae846152dbe367e7d7eb122e32c Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Fri, 10 Feb 2023 18:44:11 +0000 Subject: [PATCH] fix wrongly converted values --- openbb_terminal/helper_funcs.py | 7 ++++++- .../stocks/fundamental_analysis/fmp_model.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openbb_terminal/helper_funcs.py b/openbb_terminal/helper_funcs.py index f09cb1f1407..d698bc7c275 100644 --- a/openbb_terminal/helper_funcs.py +++ b/openbb_terminal/helper_funcs.py @@ -683,7 +683,12 @@ def lambda_long_number_format(num, round_decimal=3) -> str: return f"{num_str} {' KMBTP'[magnitude]}".strip() if isinstance(num, int): num = str(num) - if isinstance(num, str) and num.lstrip("-").isdigit(): + if ( + isinstance(num, str) + and num.lstrip("-").isdigit() + and not num.lstrip("-").startswith("0") + and not is_valid_date(num) + ): num = int(num) num /= 1.0 magnitude = 0 diff --git a/openbb_terminal/stocks/fundamental_analysis/fmp_model.py b/openbb_terminal/stocks/fundamental_analysis/fmp_model.py index 3375029e31d..70932411383 100644 --- a/openbb_terminal/stocks/fundamental_analysis/fmp_model.py +++ b/openbb_terminal/stocks/fundamental_analysis/fmp_model.py @@ -540,9 +540,20 @@ def clean_metrics_df(data: pd.DataFrame, num: int, mask: bool = True) -> pd.Data # iloc will fail if number is greater than number of columns num = min(num, data.shape[1]) data = data.iloc[:, 0:num] + if mask: data = data.mask(data.astype(object).eq(num * ["None"])).dropna() data = data.mask(data.astype(object).eq(num * ["0"])).dropna() + + date_rows = { + "calendarYear": "%Y", + "fillingDate": "%Y-%m-%d", + "acceptedDate": "%Y-%m-%d %H:%M:%S", + } + for row, dt_type in date_rows.items(): + if row in data.index: + data.loc[row] = pd.to_datetime(data.loc[row], format=dt_type) + data = data.applymap(lambda x: lambda_long_number_format(x)) clean_df_index(data) data.columns.name = "Fiscal Date Ending"