# -*- coding: utf-8 -*- """ Spyder 编辑器 这是一个临时脚本文件。 """ import os import pandas as pd pd.set_option('chained_assignment', None) select_cols = ['遥测名称', '遥测别名', '风场', '组件', '风机号', '测点'] origin_col_map = { 'wind_turbine_number': '风机编号', 'wind_turbine_name': '风机原始名称', 'time_stamp': '时间戳', 'active_power': '有功功率', 'rotor_speed': '风轮转速', 'generator_speed': '发电机转速', 'wind_velocity': '风速', 'pitch_angle_blade_1': '桨距角1', 'pitch_angle_blade_2': '桨距角2', 'pitch_angle_blade_3': '桨距角3', 'cabin_position': '机舱位置', 'true_wind_direction': '绝对风向', 'yaw_error1': '对风角度', 'set_value_of_active_power': '有功功率设定值', 'gearbox_oil_temperature': '齿轮箱油温', 'generatordrive_end_bearing_temperature': '发电机驱动端轴承温度', 'generatornon_drive_end_bearing_temperature': '发电机非驱动端轴承温度', 'cabin_temperature': '机舱内温度', 'twisted_cable_angle': '扭缆角度', 'front_back_vibration_of_the_cabin': '机舱前后振动', 'side_to_side_vibration_of_the_cabin': '机舱左右振动', 'actual_torque': '实际力矩', 'given_torque': '给定力矩', 'clockwise_yaw_count': '顺时针偏航次数', 'counterclockwise_yaw_count': '逆时针偏航次数', 'unusable': '不可利用', 'power_curve_available': '功率曲线可用', 'required_gearbox_speed': '齿轮箱转速', 'inverter_speed_master_control': '变频器转速(主控)', 'outside_cabin_temperature': '环境温度', 'main_bearing_temperature': '主轴承轴承温度', 'gearbox_high_speed_shaft_bearing_temperature': '齿轮箱高速轴轴承温度', 'gearboxmedium_speed_shaftbearing_temperature': '齿轮箱中速轴轴承温度', 'gearbox_low_speed_shaft_bearing_temperature': '齿轮箱低速轴轴承温度', 'generator_winding1_temperature': '发电机绕组1温度', 'generator_winding2_temperature': '发电机绕组2温度', 'generator_winding3_temperature': '发电机绕组3温度', 'wind_turbine_status': '风机状态1', 'wind_turbine_status2': '风机状态2', 'turbulence_intensity': '湍流强度' } def save_df(df, name): df.to_excel(r'C:\Users\wzl\Desktop\中广核104测点\total' + os.sep + str(name) + '.xlsx', columns=select_cols, index=False) def common_measurepoint(df, name): df['风场'] = df['遥测别名'].apply(lambda x: x.split('.')[0]) df['组件'] = df['遥测别名'].apply(lambda x: x.split('.')[3]) df['风机号'] = df['遥测别名'].apply(lambda x: x.split('.')[2]) df['测点'] = df['遥测别名'].apply(lambda x: '.'.join(x.split('.')[4:])) save_df(df, name + '测点') return df if __name__ == '__main__': df = pd.read_csv(r"D:\data\tmp\12CZYC.csv", encoding='gbk') df = df[~ df['遥测别名'].str.contains('Farm')] df = df[~ df['遥测别名'].str.contains('Statistics')] # 添加右玉处理 name = '右玉' youyu_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加平陆处理 name = '平陆' pinglu_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加芮城处理 name = '芮城' ruicheng_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加盂县处理 name = '盂县' yuxian_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加古交处理 name = '古交' gujiao_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加石楼处理 name = '石楼' shilou_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加阳曲处理 name = '阳曲' yangqu_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加西潘处理 name = '西潘' xipan_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加马家梁处理 name = '马家梁' majialiang_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加富风处理 name = '富风' fufeng_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加坡底处理 name = '坡底' podi_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # 添加贺家沟处理 name = '贺家沟' hejiagou_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name) # result_df = pd.concat([youyu_df, pinglu_df, ruicheng_df, yuxian_df, gujiao_df, shilou_df])