mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 20:42:26 +00:00
fix wrongly converted values
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user