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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- transition動畫z-index層級失效問題動畫Index
- 多級編號
- Index of /virtualboxIndex
- PostgreSQL:INDEXSQLIndex
- oracle invisible index與unusable index的區別OracleIndex
- CSS多級選單CSS
- Python, pandas: how to sort dataframe by index// Merge two dataframes by indexPythonIndex
- index.jspIndexJS
- null與indexNullIndex
- create index .. onlineIndex
- 帝國cms開啟升級頁面e/update/index.php是空白IndexPHP
- 小程式報錯Invoke event bindViewTap in page: pages/index/indexViewIndex
- Artificial Intelligence Index:2018年AI Index報告出爐IntelIndexAI
- PostgreSQL DBA(119) - pgAdmin(LIMIT:Index Scan vs Bitmap Index Scan)SQLMITIndex
- Elasticsearch之索引模板index template與索引別名index aliasElasticsearch索引Index
- MySQL的多層SP中Cursor的m_max_cursor_index相關BUG分析MySqlIndex
- word多級列表如何自動設定 word多級列表設定的步驟
- Android APIs (Package Index)AndroidAPIPackageIndex
- z-index:autoIndex
- flag在index裡Index
- css z-indexCSSIndex
- enable_index_filterIndexFilter
- for while改變indexWhileIndex
- Index of /debian-cd/Index
- Objective Evaluation Index of imageObjectIndex
- 7.2 FM Index MatchingIndex
- k05_多級快取快取
- Vue 遞迴多級選單Vue遞迴
- 多級快取架構(六)快取架構
- conftest 怎麼支援多級別
- Bitmap Indexing in DBMS Bitmap Index vs. B-tree Index low cardinalityIndex
- 層級查詢並將層級拆分成多列
- hive orc表'orc.create.index'='true'與'orc.create.index'='false'HiveIndexFalse
- z-index屬性Index
- 佈局 - z-indexIndex
- PostgreSQL DBA(59) - Index(Bloom)SQLIndexOOM
- PostgreSQL DBA(52) - Index(RUM)SQLIndex
- PostgreSQL DBA(47) - Index(Btree)SQLIndex