import pandas as pd import numpy as np def split_csv_to_3d_matrix(file_path, time_step=10): # 读取CSV文件 df = pd.read_csv(file_path) # 获取总行数和列数 total_rows, total_cols = df.shape # 计算时间步数 num_steps = total_rows // time_step # 初始化三维矩阵 matrix_3d = np.zeros((num_steps, time_step, total_cols), dtype=np.float) # 分割数据到三维矩阵 for step in range(num_steps): start_row = step * time_step end_row = start_row + time_step matrix_3d[step, :, :] = df.iloc[start_row:end_row, :].values return matrix_3d # 示例用法 file_path = r'D:\pycharmProjects\python_server\NormalizeData\0b976697eae74888be8a12c87d399763_wavelet_denoised_kalman_denoised_normalized.csv' # 替换为你的CSV文件路径 time_step = 10 # 指定时间步大小 # 分割CSV文件到三维矩阵 matrix_3d = split_csv_to_3d_matrix(file_path, time_step) print(matrix_3d[0], '\n', matrix_3d[1])