mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-11 22:09:44 +00:00
Increase the accuracy of reading Excel (#1209)
This commit is contained in:
@@ -1,6 +1,22 @@
|
||||
import math
|
||||
|
||||
# def csv_colunm_foramt(val):
|
||||
# if str(val).find("$") >= 0:
|
||||
# return float(val.replace("$", "").replace(",", ""))
|
||||
# if str(val).find("¥") >= 0:
|
||||
# return float(val.replace("¥", "").replace(",", ""))
|
||||
# return val
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def csv_colunm_foramt(val):
|
||||
if str(val).find("$") >= 0:
|
||||
return float(val.replace("$", "").replace(",", ""))
|
||||
if str(val).find("¥") >= 0:
|
||||
return float(val.replace("¥", "").replace(",", ""))
|
||||
return val
|
||||
try:
|
||||
if pd.isna(val):
|
||||
return math.nan
|
||||
if str(val).find("$") >= 0:
|
||||
return float(val.replace("$", "").replace(",", ""))
|
||||
if str(val).find("¥") >= 0:
|
||||
return float(val.replace("¥", "").replace(",", ""))
|
||||
return val
|
||||
except ValueError:
|
||||
return val
|
||||
|
Reference in New Issue
Block a user