You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
640 B

"""
"""
import pandas as pd
def read_csv(file_path: str) -> pd.DataFrame:
"""
CSV 文件中加载 DataFrame 对象
Args:
file_path (str): CSV 文件的路径
Returns:
DataFrame: CSV 文件中加载的 DataFrame 对象
"""
try:
df = pd.read_csv(file_path, index_col="date", parse_dates=["date"])
print(f"成功读取文件: {file_path}")
except FileNotFoundError:
print(f"找不到文件: {file_path}")
df = pd.DataFrame()
except Exception as e:
print(f"读取文件时发生错误: {e}")
df = pd.DataFrame()
return df