#0_说明:机器学习采集训练样本时,批量获得了多组csv数据,输入关键位置进行数据分割 import pandas as pd from pandas.core.frame import DataFrame #1_constant:该程序中的常量 data_path = './11_data/1_DataSegmentation(copy).csv' new_data_path = './11_data/2_NewData-' segmented_location = [499,799,1099,1399,1699,1999,2199,2499,2899,3409] #2_/Custom variable:自定义变量 j = 0 k = 0 temp = [] data = pd.read_csv(data_path) #导入data set data = data.drop('id', axis=1)#扔掉id intermediate_variable = data.values.tolist()#csv中的DataFrame类型数据转化为list型 l_sg = len(segmented_location) l_t = int(data.shape[0])#data.shape[0]行数,data.shape[1]列数 for i in range(l_t): temp.append([]) temp[i-k].append(int(intermediate_variable[i][0])) if i == segmented_location[j]: j += 1 k = i + 1 data = DataFrame(temp) data.to_csv(new_data_path + str(j) +'.csv',index=1,header=['data']) temp = []