补充9月数据
parent
e4eb5e5e50
commit
8d14ef8691
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||||
|
<serverData>
|
||||||
|
<paths name="root@192.168.89.11:22 password">
|
||||||
|
<serverdata>
|
||||||
|
<mappings>
|
||||||
|
<mapping local="$PROJECT_DIR$" web="/" />
|
||||||
|
</mappings>
|
||||||
|
</serverdata>
|
||||||
|
</paths>
|
||||||
|
</serverData>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="pytorch_gpu" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="C:\anaconda\envs\pytorch" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="NimToolchainService">
|
||||||
|
<option name="rootPaths">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,79 +1,79 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import datetime
|
import datetime
|
||||||
from sklearn.preprocessing import LabelEncoder
|
from sklearn.preprocessing import LabelEncoder
|
||||||
import os
|
import os
|
||||||
import math
|
import math
|
||||||
import chinese_calendar as cc
|
import chinese_calendar as cc
|
||||||
is_holiday = cc.is_workday(datetime.date(2023, 10, 7))
|
is_holiday = cc.is_workday(datetime.date(2023, 10, 7))
|
||||||
print(is_holiday)
|
print(is_holiday)
|
||||||
|
|
||||||
def holiday_work(x):
|
def holiday_work(x):
|
||||||
if cc.is_workday(x):
|
if cc.is_workday(x):
|
||||||
return 0
|
return 0
|
||||||
if cc.is_holiday(x):
|
if cc.is_holiday(x):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
tq_df = pd.read_excel(r'C:\Users\鸽子\Desktop\杭州\杭州气象数据.xlsx',sheet_name=0)
|
tq_df = pd.read_excel(r'C:\Users\鸽子\Desktop\杭州\杭州气象数据.xlsx',sheet_name=0)
|
||||||
pd.set_option('display.width',None)
|
pd.set_option('display.width',None)
|
||||||
tq_df.columns = tq_df.columns.map(lambda x:x.strip())
|
tq_df.columns = tq_df.columns.map(lambda x:x.strip())
|
||||||
tq_df = tq_df[['city_name','dtdate','tem_max','tem_min','rh','rh_max','rh_min','pre','prs','prs_max','prs_min','win_s_max','win_s_min']]
|
tq_df = tq_df[['city_name','dtdate','tem_max','tem_min','rh','rh_max','rh_min','pre','prs','prs_max','prs_min','win_s_max','win_s_min']]
|
||||||
tq_df.drop_duplicates(subset='dtdate',inplace=True)
|
tq_df.drop_duplicates(subset='dtdate',inplace=True)
|
||||||
tq_df = tq_df.sort_values(by='dtdate',ascending=True)
|
tq_df = tq_df.sort_values(by='dtdate',ascending=True)
|
||||||
tq_df.reset_index(inplace=True,drop=True)
|
tq_df.reset_index(inplace=True,drop=True)
|
||||||
|
|
||||||
tq_df['dtdate'] = pd.to_datetime(tq_df['dtdate'],format='%Y%m%d')
|
tq_df['dtdate'] = pd.to_datetime(tq_df['dtdate'],format='%Y%m%d')
|
||||||
tq_df['holiday'] = tq_df['dtdate'].apply(holiday_work)
|
tq_df['holiday'] = tq_df['dtdate'].apply(holiday_work)
|
||||||
print(tq_df.columns)
|
print(tq_df.columns)
|
||||||
print(tq_df.head())
|
print(tq_df.head())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(tq_df.info())
|
print(tq_df.info())
|
||||||
def jq(y,x):
|
def jq(y,x):
|
||||||
a=365.242 * (y - 1900) + 6.2 + 15.22 * x - 1.9 * math.sin(0.262 * x)
|
a=365.242 * (y - 1900) + 6.2 + 15.22 * x - 1.9 * math.sin(0.262 * x)
|
||||||
return datetime.date(1899,12,31)+datetime.timedelta(days=int(a))
|
return datetime.date(1899,12,31)+datetime.timedelta(days=int(a))
|
||||||
# print(jq(2020,0))
|
# print(jq(2020,0))
|
||||||
jq_list=['小寒', '大寒', '立春', '雨水', '惊蛰', '春分', '清明', '谷雨', '立夏', '小满', '芒种', '夏至', '小暑', '大暑', '立秋', '处暑', '白露', '秋分', '寒露', '霜降', '立冬', '小雪', '大雪','冬至']
|
jq_list=['小寒', '大寒', '立春', '雨水', '惊蛰', '春分', '清明', '谷雨', '立夏', '小满', '芒种', '夏至', '小暑', '大暑', '立秋', '处暑', '白露', '秋分', '寒露', '霜降', '立冬', '小雪', '大雪','冬至']
|
||||||
jq_dict={}
|
jq_dict={}
|
||||||
for j in range(2019,2024):
|
for j in range(2019,2024):
|
||||||
for i in range(24):
|
for i in range(24):
|
||||||
jq_dict[jq(j,i).strftime('%Y-%m-%d')]=jq_list[i]
|
jq_dict[jq(j,i).strftime('%Y-%m-%d')]=jq_list[i]
|
||||||
# print(jq_dict)
|
print(jq_dict)
|
||||||
|
|
||||||
tq_df['24ST']=tq_df.dtdate
|
tq_df['24ST']=tq_df.dtdate
|
||||||
tq_df['24ST']=tq_df['24ST'].astype('string').map(jq_dict)
|
tq_df['24ST']=tq_df['24ST'].astype('string').map(jq_dict)
|
||||||
tq_df['24ST'].fillna(method='ffill',inplace=True)
|
tq_df['24ST'].fillna(method='ffill',inplace=True)
|
||||||
tq_df['24ST'].fillna('冬至',inplace=True)
|
tq_df['24ST'].fillna('冬至',inplace=True)
|
||||||
|
|
||||||
|
|
||||||
# data为数据集 product_tags为需要编码的特征列(假设为第一列)
|
# data为数据集 product_tags为需要编码的特征列(假设为第一列)
|
||||||
le = LabelEncoder()
|
le = LabelEncoder()
|
||||||
tq_df['24ST'] = le.fit_transform(tq_df['24ST'])
|
tq_df['24ST'] = le.fit_transform(tq_df['24ST'])
|
||||||
print(tq_df)
|
print(tq_df)
|
||||||
|
|
||||||
file2=os.getcwd()+'/气象数据.csv'
|
file2=os.getcwd()+'/气象数据.csv'
|
||||||
try:
|
try:
|
||||||
tq_df.to_csv(file2,encoding='gbk')
|
tq_df.to_csv(file2,encoding='gbk')
|
||||||
except:
|
except:
|
||||||
tq_df.to_csv(file2,encoding='utf-8')
|
tq_df.to_csv(file2,encoding='utf-8')
|
||||||
|
|
||||||
elec_df = pd.read_excel(r'C:\Users\鸽子\Desktop\杭州\杭州日电量.xlsx')
|
elec_df = pd.read_excel(r'C:\Users\鸽子\Desktop\杭州\杭州日电量.xlsx')
|
||||||
elec_df['售电量'] = (elec_df['售电量']/10000).map(lambda x:round(x,2))
|
elec_df['售电量'] = (elec_df['售电量']/10000).map(lambda x:round(x,2))
|
||||||
|
|
||||||
print(elec_df.columns)
|
print(elec_df.columns)
|
||||||
elec_df.sort_values(by=' 天 ',ascending=True,inplace=True)
|
elec_df.sort_values(by=' 天 ',ascending=True,inplace=True)
|
||||||
elec_df[' 天 '] = pd.to_datetime(elec_df[' 天 '],format='%Y%m%d')
|
elec_df[' 天 '] = pd.to_datetime(elec_df[' 天 '],format='%Y%m%d')
|
||||||
print(elec_df.info())
|
print(elec_df.info())
|
||||||
print(elec_df)
|
print(elec_df)
|
||||||
|
|
||||||
df = pd.merge(tq_df,elec_df,left_on='dtdate',right_on=' 天 ')
|
df = pd.merge(tq_df,elec_df,left_on='dtdate',right_on=' 天 ')
|
||||||
df.drop(columns=' 天 ',inplace=True)
|
df.drop(columns=' 天 ',inplace=True)
|
||||||
|
|
||||||
df.set_index('dtdate',inplace=True,drop=True)
|
df.set_index('dtdate',inplace=True,drop=True)
|
||||||
print(df)
|
print(df)
|
||||||
df.to_csv(os.getcwd()+'\入模数据.csv',encoding='gbk')
|
df.to_csv(os.getcwd()+'\入模数据.csv',encoding='gbk')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue