- 博客(6)
- 收藏
- 关注
原创 pandas数据透视表 pd.pivot_table()
pandas.pivot_table() 几个重要的参数 data:DataFrame对象 values:源数据中的一列,数据透视表中用于观察分析的数据值,类似Excel中的值字段 index:源数据中的一列,数据透视表用于行索引的数据值,类似Excel中的行字段 columns:源数据中的一列,数据透视表用于列索引的数据值,类似Excel中列字段 aggfunc:根据当前的行、列索引...
2018-07-19 21:35:58
8139
翻译 8.2. 定制的字符串格式化
Method __format__() Discussion 定义一个类 _formats = { 'ymd' : '{d.year}-{d.month}-{d.day}', 'mdy' : '{d.month}/{d.day}/{d.year}', 'dmy' : '{d.day}/{d.month}/{d.year}' } class Date: def
2018-01-06 20:35:31
213
翻译 8.1. 改变类实例的表示
Method __repr__() __str__() Discussion 定义一个类如下 class Pair: def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return 'Pair({0.x!r}, {0.y!r})'.fo
2018-01-06 20:20:28
203
翻译 2.2. 匹配字符串的头或尾
Method str.startswith() str,endswith() Discussion 检查字符串首尾的简单方法 >>> filename = 'spam.txt' >>> filename.endswith('.txt') True >>> filename.startswith('file:') False >>> url = 'http://www.python
2018-01-06 18:19:25
2148
翻译 2.1. 多分隔符字符串划分
Method str.split() re.split() str.split()方法适用于简单的情形,对于多分隔符的情况需要使用re.split() Discussion 类似str.split()的操作 >>> line = 'asdf fjdk; afed, fjek,asdf, foo' >>> import re >>> re.split(r'[;,\s]\s*', li
2018-01-06 16:49:41
345
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人