{ "cells": [ { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1441\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "import os\n", "folder_path = \"/home/liuzhongxiao/project/zlwl-algos/USER/liuzhongxiao/SOC_Fct/\" # 设置相对路径\n", "csv_files = [file for file in os.listdir(folder_path) if file.endswith('.csv')]\n", "# 遍历所有CSV文件并依次读取它们\n", "df_data_all = pd.DataFrame()\n", "for csv_file in csv_files:\n", " filename = os.path.join(folder_path, csv_file)\n", " df_data = pd.read_csv(filename)\n", " df_data_all = df_data_all.append(df_data)\n", "print(len(df_data_all))" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " sn time soc_ori soc_pre soc_error odo \\\n", "0 LY9139BB1MALBZ799 2022-08-29 01:39:02 [46] [54.0] [8.0] 0 \n", "1 LY9139BB1MALBZ799 2022-11-17 11:02:13 [46] [50.1] [4.1] 0 \n", "2 LY9139BB1MALBZ799 2022-01-22 01:52:57 [50] [44.4] [-5.6] 0 \n", "3 LY9139BB1MALBZ799 2022-06-18 11:10:30 [51] [45.8] [-5.2] 0 \n", "4 LY9139BB1MALBZ799 2022-02-12 12:45:13 [51] [47.3] [-3.7] 0 \n", "\n", " method battery_type soc_errorV \n", "0 1 lfp 8.0 \n", "1 1 lfp 4.1 \n", "2 1 lfp 5.6 \n", "3 1 lfp 5.2 \n", "4 1 lfp 3.7 \n" ] } ], "source": [ "print(df_data_all.head(5))" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 8.0\n", "1 4.1\n", "2 5.6\n", "3 5.2\n", "4 3.7\n", "Name: soc_errorV, dtype: float64\n" ] } ], "source": [ "df_data_all['soc_errorV'] = df_data_all['soc_error'].apply(lambda x: max(np.abs(eval(x))))\n", "df_data_all['soc_errorV'].iloc[0]\n", "print(df_data_all['soc_errorV'].iloc[0:5])" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "# df_data_chs = df_data_all[df_data_all['soc_errorV'] > 10]\n", "# df_data_chs.reset_index(drop=True, inplace=True)\n", "df_data_all.to_csv('./' + 'SOC估计结果汇总V.csv',index=False,encoding='GB18030')" ] } ], "metadata": { "kernelspec": { "display_name": "py3916", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }