import pandas as pd import re def getNum(x): """ 科学计数法和字符转浮点数 """ if re.findall(r‘\d+\.\d+E\+‘,x): return "%.f" % float(x) elif x=="C": return 1 else: return x df = pd.DataFrame({"x":[2030,1.11002E+11,2030,1.11002E+11,"C"]}) df["x"] = df["x"].astype("str") df["x"] = df["x"].apply(getNum) df["x"] = pd.to_numeric(df["x"]) df["x"] = df["x"].astype("int64")
原文地址:https://www.cnblogs.com/wzdLY/p/9885877.html
时间: 2024-11-13 02:33:40