4.Pandas多級Index
import numpy as np
import pandas as pd
from pandas import Series,DataFrame
Series的多級Index
s1 = Series(
np.random.randn(6),
index = [['1','1','1','2','2','2'],['a','b','c','a','b',c']]
)
1.此時的Series是二維的資料結構
2.可以將它轉換成DataFrame
df1 = s1.unstack()
df2 = DataFrame([s1['1'],s1['1']])
#將DataFrame再轉換回Series
s2 = df1.unstack()
s2 = df1.T.unstack()
DataFrame的多級Index
df = DataFrame(np.arange(16).reshape(4,4))
df = DataFrame(
np.arange(16).reshape(4,4),
index = [['a','a','b','b'],[1,2,1,2]],
columns = ['A','B','C','D']
)
睡覺了=_=,把最後一個補上。
以後寫的手記都會加上順序,主要寫兩個類別的,資料分析類&演算法類的,其他的後續再補上
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/854/viewspace-2822325/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 4.pandas基礎使用
- transition動畫z-index層級失效問題動畫Index
- 多級編號
- KEEP INDEX | DROP INDEXIndex
- CSS多級選單CSS
- rowid,index,INDEX FULL SCAN,INDEX FAST FULL SCAN|IndexAST
- INDEX UNIQUE SCAN,INDEX FULL SCAN和INDEX FAST FULL SCANIndexAST
- Clustered Index Scan and Clustered Index SeekIndex
- oracle hint之full,index,index_asc,index_desc,index_combile示例OracleIndex
- IndexIndex
- Index的掃描方式:index full scan/index fast full scanIndexAST
- rebuild index 和 recreate index (重新建立index) 的區別RebuildIndex
- pk 、unique index 和 index 區別Index
- global index & local index的區別Index
- alter index rebuild與index_statsIndexRebuild
- word多級列表如何自動設定 word多級列表設定的步驟
- Vue 遞迴多級選單Vue遞迴
- 多級快取架構(六)快取架構
- k05_多級快取快取
- B-index、bitmap-index、text-index使用場景詳解Index
- Index Full Scan vs Index Fast Full ScanIndexAST
- Using index condition Using indexIndex
- 【Oracle】global index & local index的區別OracleIndex
- Index Full Scans和Index Fast Full ScansIndexAST
- What is meant by Primary Index and Secondary IndexIndex
- Index Full Scan 與 Index Fast Full ScanIndexAST
- 層級查詢並將層級拆分成多列
- apache 部署多 PHP 版本、多專案以及二級域名ApachePHP
- PostgreSQL:INDEXSQLIndex
- <MYSQL Index>MySqlIndex
- jQuery index()jQueryIndex
- index索引Index索引
- rebuild indexRebuildIndex
- index rebuildIndexRebuild
- Bitmap IndexIndex
- index range scan,index fast full scan,index skip scan發生的條件IndexAST
- 幾行程式碼實現ListView的多級聯動——多級聯動就是如此簡單行程View
- create index/create index online區別Index