pandas 学习 —— pivot table
来源:互联网 发布:seo外链资源 编辑:程序博客网 时间:2024/06/05 14:17
0. DataFrame 的 index、columns、values
>> df = pd.DataFrame(np.arange(6).reshape(3, 2), index=['one', 'two', 'three'], columns=['a', 'b'])>> df a bone 0 1two 2 3three 4 5>> df.indexIndex(['one', 'two', 'three'], dtype='object')>> df.columnsIndex(['a', 'b'], dtype='object')>> df.valuesarray([[0, 1], [2, 3], [4, 5]])
1. 认识 pivot table
>> df = pd.DataFrame({'foo': ['one','one','one','two','two','two'], 'bar': ['A', 'B', 'C', 'A', 'B', 'C'], 'baz': [1, 2, 3, 4, 5, 6]}) # 通过字典的方式构造 DataFrame>> df bar baz foo0 A 1 one1 B 2 one2 C 3 one3 A 4 two4 B 5 two5 C 6 two>> df.pivot(index='foo', columns='bar', values='baz')bar A B Cfooone 1 2 3two 4 5 6>> df.pivot(index='bar', columns='foo', values='baz')foo one twobarA 1 4B 2 5C 3 6
可见 pivot 是对原始 dataframe 展示样式的重新组织和排列。
阅读全文
0 0
- pandas 学习 —— pivot table
- pandas学习笔记3—数据重塑图解Pivot, Pivot-Table, Stack and Unstack
- Pandas——NaN&Pivot&dropna&reset_index
- python pandas库——pivot使用心得
- pandas pivot
- pandas RESHAPING AND PIVOT TABLES
- c# Pivot Table 操作
- EXCEL Pivot table manipulate
- pandas学习笔记4—factorize()
- pandas 学习(二)—— pandas 下的常用函数
- WP8.1学习系列(第七章)——应用选项卡Pivot交互UX
- WP8.1学习系列(第八章)——透视Pivot设计指南
- WP8.1学习系列(第九章)——透视Pivot开发指南
- 学习使用PIVOT
- 【Pivot Stickfigure Animator】——PeppaPig
- lua学习笔记—table
- pandas 学习(一) —— data frame
- pandas 学习(五)—— datetime(日期)
- PHP mysqli_free_result()与mysqli_fetch_array()函数
- pythonic之路(一)
- pat甲级1002
- 删除购物车
- newlife
- pandas 学习 —— pivot table
- 主函数
- 读书笔记——《Head First Java》MIDI音乐播放器实例
- Android 自定义构建类型 BuildType
- 风投的宠儿
- 阻塞queue系列之LinkedBlockingDeque
- js cookie设置cookie, 删除cookie, 获取cookie,清空cookie
- python进阶
- 动画