動手學資料分析 task3 資料重構

2021-10-23 17:38:38 字數 1649 閱讀 8443

一、資料合併

1、使用pd.concat(objs, axis=0, join=『outer』, […])

list_up =

[text_left_up,text_right_up]

result_up = pd.concat(list_up,axis=1)

result_up.head(

)

resul_up = text_left_up.join(text_right_up)

result_down = text_left_down.join(text_right_down)

result.head(

)

result_up = pd.merge(text_left_up,text_right_up,left_index=

true

,right_index=

true

)result_down = pd.merge(text_left_down,text_right_down,left_index=

true

,right_index=

true

)result.head(

)

二、stack函式作用?

常見的資料的層次化結構有兩種,一種是**,一種是「花括號」,即下面這樣的l兩種形式:

**在行列方向上均有索引(類似於dataframe),花括號結構只有「列方向」上的索引(類似於層次化的series),結構更加偏向於堆疊(series-stack,方便記憶)。stack函式會將資料從」**結構「變成」花括號結構「,即將其行索引變成列索引。另外,unstack函式將資料從」花括號結構「變成」**結構「,即要將其中一層的列索引變成行索引。

三、資料聚合與運算

1、group by:一般和sum()、mean()等聚合函式一起,使用預設axis=0按行分組,可指定axis=1對列分組。欄位內的資料重構後都會變成索引

df  = text[

'fare'

].groupby(text[

'***'])

means = df.mean(

)survived_*** = text[

'survived'

].groupby(text[

'***'])

.sum()

survived_pclass = text[

'survived'

].groupby(text[

'pclass'])

survived_pclass.

sum(

)

2、1中的運算可以通過agg()函式來同時計算,且可以使用rename函式修改列名

df.groupby(

'survived'

).agg(

).rename(columns=

)

動手學資料分析 Task3

concat方法可以在兩個維度上拼接,預設縱向憑藉 axis 0 拼接方式缺省外連線 pd.concat objs,axis 0,join outer join axes none,ignore index false,keys none,levels none,names none,verify ...

動手學深度學習Task3

過擬合 欠擬合及其解決方案 梯度消失 梯度 迴圈神經網路高階 1 過擬合和欠擬合 過擬合 模型的訓練誤差遠小於它在測試資料集上的誤差,我們稱該現象為過擬合 欠擬合 模型訓練誤差無法降低.如何應對欠擬合和過擬合?在這裡我們重點討論兩個因素 模型複雜度和訓練資料集大小。1.1.1 模型複雜度 為了解釋模...

動手學資料分析 Task 2

常用的函式有dropna 和fillna dataframe.dropna axis 0,how any thresh none,subset none,inplace false 屬性說明 預設引數axis 0,根據索引 index 刪除指定的行 axis 1,根據列名 columns 刪除指定的...