資源簡介
時序數據數據預處理、特征提取代碼。分段特征、統計特征、熵特征。
代碼片段和文件信息
#?-*-?coding:?utf-8?-*-#
#-------------------------------------------------------------------------------
#?Name:?????????beautiful
#?Description:??
#?Author:???????shichao
#?Date:?????????2019/5/8
#-------------------------------------------------------------------------------
import?os
import?numpy?as?np
import?pandas?as?pd
from?sklearn.model_selection?import?train_test_split
import?time
import?datetime
#?核心代碼,設置顯示的最大列、寬等參數,消掉打印不完全中間的省略號
pd.set_option(‘display.max_columns‘?1000)
pd.set_option(‘display.width‘?1000)
pd.set_option(‘display.max_colwidth‘?1000)
#?讀取數據
def?read_df(file_name):
????file_dir?=?‘./‘
????file_path?=?os.path.join(file_dir?file_name)
????file_path?=?open(file_path)
????df_file?=?pd.read_csv(file_path)
????df_file[‘DateTime‘]?=?pd.to_datetime(df_file[‘DateTime‘])
????df_file?=?df_file.sort_values(by=‘DateTime‘)
????return?df_file
#?對?x?增加特征:date_ymd?年月日、把年月日時分秒轉化為秒數utc時間
def?add_features(df_file):
????date_list?=?[]
?
- 上一篇:圖書借閱管理系統 附數據庫
- 下一篇:app inventor游戲2048
評論
共有 條評論