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

41 lines
1.9 KiB
Python

import os
import numpy as np
import pandas as pd
n1 = np.array([[1,1,1]])
n2 = np.array([1,1,1]).reshape(1,-1)
print(n2)
n2 = np.array([]).reshape(3,-1)
print(np.max([[1,2,3],[4,5,6]]))
# file_dir = r'C:\Users\user\Desktop\浙江各地市分电压日电量数据'
# df = pd.read_excel(r'C:\Users\user\Desktop\浙江省各地市日电量及分压数据21-23年.xlsx',sheet_name=1)
# df.columns = df.columns.map(lambda x:x.strip())
# for city in df['地市'].drop_duplicates():
# df_city = df[df['地市']== city]
# df_city['stat_date'] = df_city['stat_date'].map(lambda x:x.strip())
# df_city['stat_date'] = pd.to_datetime(df_city['stat_date'],format='%Y-%m-%d')
# df_city = df_city[df_city.columns[:-1]]
# df_city.sort_values(by='stat_date',ascending=True,inplace=True)
# df_city['stat_date'] = df_city['stat_date'].astype('str')
# df_city.to_excel(fr'C:\Users\user\Desktop\浙江各地市分电压日电量数据\{city}.xlsx',index=False)
# file_Dir = r'C:\Users\鸽子\Desktop\浙江各地市行业电量数据'
# for excel in os.listdir(file_Dir):
# df1 = pd.read_excel(r'C:\Users\鸽子\Desktop\浙江各地市日电量数据-27-28).xlsx',sheet_name=1)
# df1.columns = df1.columns.map(lambda x:x.strip())
# df2 = pd.read_excel(os.path.join(file_Dir,excel))
# df2['地市'] = df2['地市'].map(lambda x:x.strip())
# city = df2['地市'].iloc[0]
# col_list = df2.columns
# df1 = df1[col_list]
# df1 = df1[(df1['stat_date']==20231028)&(df1['地市']==city)]
# df1['stat_date'] = pd.to_datetime(df1['stat_date'],format='%Y%m%d')
# df2 = pd.concat((df2,df1),ignore_index=True)
# df2.to_excel(fr'C:\Users\鸽子\Desktop\浙江各地市行业电量数据\{city}.xlsx')
df = pd.read_csv(r'C:\Users\鸽子\Desktop\浙江各区县数据(2).csv')
df.columns = df.columns.map(lambda x:x.strip())
print(df.columns)
print(dict(zip(df.columns,[(df[x]==0).sum()/len(df) for x in df.columns])))