当前位置: 首页 > news >正文

没人和我重复标题!第1章 Pandas基础

第1章 Pandas基础

查看Pandas版本(本教程全部使用1.0.0版本)
import pandas as pd
import numpy as np
pd.__version__
'0.25.1'

一、文件读取与写入

1. 读取

(a)csv格式
df = pd.read_csv('data/table.csv')
df.head()    #head()函数,读取前5行,原型默认参数为5
SchoolClassIDGenderAddressHeightWeightMathPhysics
0S_1C_11101Mstreet_11736334.0A+
1S_1C_11102Fstreet_21927332.5B+
2S_1C_11103Mstreet_21868287.2B+
3S_1C_11104Fstreet_21678180.4B-
4S_1C_11105Fstreet_41596484.8B+
(b)txt格式
df_txt = pd.read_table('data/table.txt') #可设置sep分隔符参数 ,‘\t’默认由tab分割
df_txt
col1col2col3col4
02a1.4apple
13b3.4banana
26c2.5orange
35d3.2lemon
(c)xls或xlsx格式
#需要安装xlrd包
df_excel = pd.read_excel('data/table.xlsx')
df_excel.head()
SchoolClassIDGenderAddressHeightWeightMathPhysics
0S_1C_11101Mstreet_11736334.0A+
1S_1C_11102Fstreet_21927332.5B+
2S_1C_11103Mstreet_21868287.2B+
3S_1C_11104Fstreet_21678180.4B-
4S_1C_11105Fstreet_41596484.8B+

2. 写入

(a)csv格式
names = ['Bob','Jessica','Mary','John','Mel']
births = [968,155,77,578,973]
DataSet = list(zip(names,births))   #用 zip 函数将这两个列表合并
DataSet
df = pd.DataFrame(data = DataSet ,columns=['Names','Births'])   #生成一个DataFrame对象
df
df.to_csv('data/new_table.csv')
(b)xls或xlsx格式
#需要安装openpyxl
df.to_excel('data/new_table2.xlsx', sheet_name='Sheet1')

二、基本数据结构

1. Series

(a)创建一个Series (类似一维数组)
对于一个Series,其中最常用的属性为值(values),索引(index),名字(name),类型(dtype)
s = pd.Series(np.random.randn(5),index=['a','b','c','d','e'],name='一个Series',dtype='float64')  #一个符合标准正态分布的Series
s
a   -0.377312
b   -0.229854
c   -1.465434
d   -0.840431
e    0.527155
Name: 一个Series, dtype: float64
(b)访问Series属性
s.values
array([-0.37731161, -0.22985384, -1.4654339 , -0.84043107,  0.52715519])
s.name
'一个Series'
s.index
Index(['a', 'b', 'c', 'd', 'e'], dtype='object')
s.dtype
dtype('float64')
(c)取出某一个元素
将在第2章详细讨论索引的应用,这里先大致了解
s['a']
-0.3773116135477631
(d)调用方法
s.mean()   #平均值
-0.4771750456994931
Series有相当多的方法可以调用:
print([attr for attr in dir(s) if not attr.startswith('_')])
['T', 'a', 'abs', 'add', 'add_prefix', 'add_suffix', 'agg', 'aggregate', 'align', 'all', 'any', 'append', 'apply', 'argmax', 'argmin', 'argsort', 'array', 'as_matrix', 'asfreq', 'asof', 'astype', 'at', 'at_time', 'autocorr', 'axes', 'b', 'base', 'between', 'between_time', 'bfill', 'bool', 'c', 'clip', 'clip_lower', 'clip_upper', 'combine', 'combine_first', 'compound', 'compress', 'copy', 'corr', 'count', 'cov', 'cummax', 'cummin', 'cumprod', 'cumsum', 'd', 'data', 'describe', 'diff', 'div', 'divide', 'divmod', 'dot', 'drop', 'drop_duplicates', 'droplevel', 'dropna', 'dtype', 'dtypes', 'duplicated', 'e', 'empty', 'eq', 'equals', 'ewm', 'expanding', 'explode', 'factorize', 'ffill', 'fillna', 'filter', 'first', 'first_valid_index', 'flags', 'floordiv', 'from_array', 'ftype', 'ftypes', 'ge', 'get', 'get_dtype_counts', 'get_ftype_counts', 'get_values', 'groupby', 'gt', 'hasnans', 'head', 'hist', 'iat', 'idxmax', 'idxmin', 'iloc', 'imag', 'index', 'infer_objects', 'interpolate', 'is_monotonic', 'is_monotonic_decreasing', 'is_monotonic_increasing', 'is_unique', 'isin', 'isna', 'isnull', 'item', 'items', 'itemsize', 'iteritems', 'ix', 'keys', 'kurt', 'kurtosis', 'last', 'last_valid_index', 'le', 'loc', 'lt', 'mad', 'map', 'mask', 'max', 'mean', 'median', 'memory_usage', 'min', 'mod', 'mode', 'mul', 'multiply', 'name', 'nbytes', 'ndim', 'ne', 'nlargest', 'nonzero', 'notna', 'notnull', 'nsmallest', 'nunique', 'pct_change', 'pipe', 'plot', 'pop', 'pow', 'prod', 'product', 'ptp', 'put', 'quantile', 'radd', 'rank', 'ravel', 'rdiv', 'rdivmod', 'real', 'reindex', 'reindex_like', 'rename', 'rename_axis', 'reorder_levels', 'repeat', 'replace', 'resample', 'reset_index', 'rfloordiv', 'rmod', 'rmul', 'rolling', 'round', 'rpow', 'rsub', 'rtruediv', 'sample', 'searchsorted', 'sem', 'set_axis', 'shape', 'shift', 'size', 'skew', 'slice_shift', 'sort_index', 'sort_values', 'squeeze', 'std', 'strides', 'sub', 'subtract', 'sum', 'swapaxes', 'swaplevel', 'tail', 'take', 'to_clipboard', 'to_csv', 'to_dense', 'to_dict', 'to_excel', 'to_frame', 'to_hdf', 'to_json', 'to_latex', 'to_list', 'to_msgpack', 'to_numpy', 'to_period', 'to_pickle', 'to_sparse', 'to_sql', 'to_string', 'to_timestamp', 'to_xarray', 'transform', 'transpose', 'truediv', 'truncate', 'tshift', 'tz_convert', 'tz_localize', 'unique', 'unstack', 'update', 'value_counts', 'values', 'var', 'view', 'where', 'xs']

2. DataFrame

(a)创建一个DataFrame
df = pd.DataFrame({'col1':list('abcde'),'col2':range(5,10),'col3':[2,2.5,3.6,4.6,5.8]},index=list('一二三四五'))   #dataframe{列名:对应值,索引}
df
col1col2col3
a52.0
b62.5
c73.6
d84.6
e95.8
(b)从DataFrame取出一列为Series
df['col1']
一    a
二    b
三    c
四    d
五    e
Name: col1, dtype: object
type(df)  #数据类型
pandas.core.frame.DataFrame
type(df['col1']) #取出dataframe的一列的类型,结果为series
pandas.core.series.Series
(c)修改行或列名
df.rename(index={'一':'one','五':'five'},columns={'col1':'new_col1','col3':'new_col3'})  #index/columns={旧名称:新名称}
new_col1col2new_col3
onea52.0
b62.5
c73.6
d84.6
fivee95.8
(d)调用属性和方法
df.index   #取索引,即行名
Index(['一', '二', '三', '四', '五'], dtype='object')
df.columns  #取列名
Index(['col1', 'col2', 'col3'], dtype='object')
df.values   #取dataframe的数值(类型为矩阵)
array([['a', 5, 1.3],['b', 6, 2.5],['c', 7, 3.6],['d', 8, 4.6],['e', 9, 5.8]], dtype=object)
df.shape #数据库维度
(5, 3)
df.mean() #本质上是一种Aggregation操作,将在第3章详细介绍  (列的运算)
col2    3.0
col3    3.7
dtype: float64
(e)索引对齐特性
这是Pandas中非常强大的特性,不理解这一特性有时就会造成一些麻烦
df1 = pd.DataFrame({'A':[1,2,3]},index=[1,2,3])
df2 = pd.DataFrame({'A':[1,2,3]},index=[3,2,1])
df1-df2 #由于索引对齐,因此结果不是0,索引对应做运算
A
1-2
20
32
(f)列的删除与添加
对于删除而言,可以使用drop函数或del或pop
df.drop(index='五',columns='col1') #设置inplace=True后会直接在原DataFrame中改动
col2col3
12.0
22.5
33.6
44.6
55.8
df['col1']=[1,2,3,4,5]
del df['col1']
df
col2col3
52.0
62.5
73.6
84.6
95.8
pop方法直接在原来的DataFrame上操作,且返回被删除的列,与python中的pop函数类似
df['col1']=[1,2,3,4,5]
df.pop('col1')
一    1
二    2
三    3
四    4
五    5
Name: col1, dtype: int64
df
col2col3
52.0
62.5
73.6
84.6
95.8
可以直接增加新的列,也可以使用assign方法
df1['B']=list('abc')
df1
AB
11a
22b
33c

df1.assign(C=pd.Series(list(‘def’)))

但assign方法不会对原DataFrame做修改
df1
AB
11a
22b
33c
(g)根据类型选择列
df.select_dtypes(include=['number']).head()
col2col3
52.0
62.5
73.6
84.6
95.8
df.select_dtypes(include=['float']).head()
col3
2.0
2.5
3.6
4.6
5.8
(h)将Series转换为DataFrame
s = df.mean()
s.name='to_DataFrame'
s
col2    7.00
col3    3.56
Name: to_DataFrame, dtype: float64
s.to_frame()
to_DataFrame
col27.00
col33.56
使用T符号可以转置
s.to_frame().T
col2col3
to_DataFrame7.03.56

三、常用基本函数

从下面开始,包括后面所有章节,我们都会用到这份虚拟的数据集
df = pd.read_csv('data/table.csv')

1. head和tail

df.head()  #前五行
SchoolClassIDGenderAddressHeightWeightMathPhysics
0S_1C_11101Mstreet_11736334.0A+
1S_1C_11102Fstreet_21927332.5B+
2S_1C_11103Mstreet_21868287.2B+
3S_1C_11104Fstreet_21678180.4B-
4S_1C_11105Fstreet_41596484.8B+
df.tail()  #后五行
SchoolClassIDGenderAddressHeightWeightMathPhysics
30S_2C_42401Fstreet_21926245.3A
31S_2C_42402Mstreet_71668248.7B
32S_2C_42403Fstreet_61586059.7B+
33S_2C_42404Fstreet_21608467.7B
34S_2C_42405Fstreet_61935447.6B
可以指定n参数显示多少行
df.head(3)
SchoolClassIDGenderAddressHeightWeightMathPhysics
0S_1C_11101Mstreet_11736334.0A+
1S_1C_11102Fstreet_21927332.5B+
2S_1C_11103Mstreet_21868287.2B+

2. unique和nunique

nunique显示有多少个唯一值
df['Physics'].nunique()   #number unique 
7
unique显示所有的唯一值
df['Physics'].unique()
array(['A+', 'B+', 'B-', 'A-', 'B', 'A', 'C'], dtype=object)

3. count和value_counts

count返回非缺失值元素个数
df['Physics'].count()
35
value_counts返回每个元素有多少个(统计所有唯一值的个数)
df['Physics'].value_counts()
B+    9
B     8
B-    6
A     4
A+    3
A-    3
C     2
Name: Physics, dtype: int64

4. describe和info

info函数返回有哪些列、有多少非缺失值、每列的类型
df.info()
<class 'pandas.core.frame.DataFrame'>
Index: 5 entries, 一 to 五
Data columns (total 2 columns):
col2    5 non-null int64
col3    5 non-null float64
dtypes: float64(1), int64(1)
memory usage: 280.0+ bytes
describe默认统计数值型数据的各个统计量
df.describe()
IDHeightWeightMath
count35.0000035.00000035.00000035.000000
mean1803.00000174.14285774.65714361.351429
std536.8774113.54109812.89537719.915164
min1101.00000155.00000053.00000031.500000
25%1204.50000161.00000063.00000047.400000
50%2103.00000173.00000074.00000061.700000
75%2301.50000187.50000082.00000077.100000
max2405.00000195.000000100.00000097.000000
可以自行选择分位数
df.describe(percentiles=[.05, .25, .75, .95])
IDHeightWeightMath
count35.0000035.00000035.00000035.000000
mean1803.00000174.14285774.65714361.351429
std536.8774113.54109812.89537719.915164
min1101.00000155.00000053.00000031.500000
5%1102.70000157.00000056.10000032.640000
25%1204.50000161.00000063.00000047.400000
50%2103.00000173.00000074.00000061.700000
75%2301.50000187.50000082.00000077.100000
95%2403.30000193.30000097.60000090.040000
max2405.00000195.000000100.00000097.000000
对于非数值型也可以用describe函数
df['Physics'].describe()
count     35
unique     7
top       B+
freq       9
Name: Physics, dtype: object

5. idxmax和nlargest

idxmax函数返回最大值,在某些情况下特别适用,idxmin功能类似
df['Math'].idxmax()   #返回对应索引
5
nlargest函数返回前几个大的元素值,nsmallest功能类似
df['Math'].nlargest(3)  #返回索引及对应值
5     97.0
28    95.5
11    87.7
Name: Math, dtype: float64

6. clip和replace

clip和replace是两类替换函数
clip是对超过或者低于某些值的数进行截断
df['Math'].head()
0    34.0
1    32.5
2    87.2
3    80.4
4    84.8
Name: Math, dtype: float64
df['Math'].clip(33,80).head()  #小于33的都取33,大于80的都取80,33到80之间不变
0    34.0
1    33.0
2    80.0
3    80.0
4    80.0
Name: Math, dtype: float64
df['Math'].mad()  #平均绝对偏差
16.924244897959188
replace是对某些值进行替换
df['Address'].head()
0    street_1
1    street_2
2    street_2
3    street_2
4    street_4
Name: Address, dtype: object
df['Address'].replace(['street_1','street_2'],['one','two']).head()
0         one
1         two
2         two
3         two
4    street_4
Name: Address, dtype: object
通过字典,可以直接在表中修改
df.replace({'Address':{'street_1':'one','street_2':'two'}}).head()
SchoolClassIDGenderAddressHeightWeightMathPhysics
0S_1C_11101Mone1736334.0A+
1S_1C_11102Ftwo1927332.5B+
2S_1C_11103Mtwo1868287.2B+
3S_1C_11104Ftwo1678180.4B-
4S_1C_11105Fstreet_41596484.8B+

7. apply函数

apply是一个自由度很高的函数,在第3章我们还要提到
对于Series,它可以迭代每一列的值操作:
df['Math'].apply(lambda x:str(x)+'!').head() #可以使用lambda表达式,也可以使用函数
0    34.0!
1    32.5!
2    87.2!
3    80.4!
4    84.8!
Name: Math, dtype: object
对于DataFrame,它可以迭代每一个列操作:
df.apply(lambda x:x.apply(lambda x:str(x)+'!')).head() #这是一个稍显复杂的例子,有利于理解apply的功能
SchoolClassIDGenderAddressHeightWeightMathPhysics
0S_1!C_1!1101!M!street_1!173!63!34.0!A+!
1S_1!C_1!1102!F!street_2!192!73!32.5!B+!
2S_1!C_1!1103!M!street_2!186!82!87.2!B+!
3S_1!C_1!1104!F!street_2!167!81!80.4!B-!
4S_1!C_1!1105!F!street_4!159!64!84.8!B+!

四、排序

1. 索引排序

df.set_index('Math').head()#set_index函数可以设置索引,将在下一章详细介绍
SchoolClassIDGenderAddressHeightWeightPhysics
Math
34.0S_1C_11101Mstreet_117363A+
32.5S_1C_11102Fstreet_219273B+
87.2S_1C_11103Mstreet_218682B+
80.4S_1C_11104Fstreet_216781B-
84.8S_1C_11105Fstreet_415964B+
df.set_index('Math').sort_index().head() #可以设置ascending参数,默认为升序,True
SchoolClassIDGenderAddressHeightWeightPhysics
Math
31.5S_1C_31301Mstreet_416168B+
32.5S_1C_11102Fstreet_219273B+
32.7S_2C_32302Mstreet_517188A
33.8S_1C_21204Fstreet_516263B
34.0S_1C_11101Mstreet_117363A+

2. 值排序

df.sort_values(by='Class')
SchoolClassIDGenderAddressHeightWeightMathPhysics
0S_1C_11101Mstreet_11736334.0A+
19S_2C_12105Mstreet_41708134.2A
18S_2C_12104Fstreet_51599772.2B+
16S_2C_12102Fstreet_61616150.6B+
15S_2C_12101Mstreet_71748483.3C
17S_2C_12103Mstreet_41576152.5B-
1S_1C_11102Fstreet_21927332.5B+
2S_1C_11103Mstreet_21868287.2B+
3S_1C_11104Fstreet_21678180.4B-
4S_1C_11105Fstreet_41596484.8B+
6S_1C_21202Fstreet_41769463.5B-
24S_2C_22205Fstreet_71837685.4B
23S_2C_22204Mstreet_11757447.2B-
22S_2C_22203Mstreet_41559173.8A+
21S_2C_22202Fstreet_71947768.5B+
5S_1C_21201Mstreet_51886897.0A-
20S_2C_22201Mstreet_519310039.1B
9S_1C_21205Fstreet_61676368.4B-
8S_1C_21204Fstreet_51626333.8B
7S_1C_21203Mstreet_61605358.8A+
25S_2C_32301Fstreet_41577872.3B+
13S_1C_31304Mstreet_21957085.2A
12S_1C_31303Mstreet_71888249.7B
11S_1C_31302Fstreet_11755787.7A-
10S_1C_31301Mstreet_41616831.5B+
14S_1C_31305Fstreet_51876961.7B-
26S_2C_32302Mstreet_51718832.7A
27S_2C_32303Fstreet_71909965.9C
28S_2C_32304Fstreet_61648195.5A-
29S_2C_32305Mstreet_41877348.9B
32S_2C_42403Fstreet_61586059.7B+
33S_2C_42404Fstreet_21608467.7B
30S_2C_42401Fstreet_21926245.3A
31S_2C_42402Mstreet_71668248.7B
34S_2C_42405Fstreet_61935447.6B
多个值排序,即先对第一层排,在第一层相同的情况下对第二层排序
df.sort_values(by=['Address','Height'])
SchoolClassIDGenderAddressHeightWeightMathPhysics
0S_1C_11101Mstreet_11736334.0A+
11S_1C_31302Fstreet_11755787.7A-
23S_2C_22204Mstreet_11757447.2B-
33S_2C_42404Fstreet_21608467.7B
3S_1C_11104Fstreet_21678180.4B-
2S_1C_11103Mstreet_21868287.2B+
1S_1C_11102Fstreet_21927332.5B+
30S_2C_42401Fstreet_21926245.3A
13S_1C_31304Mstreet_21957085.2A
22S_2C_22203Mstreet_41559173.8A+
17S_2C_12103Mstreet_41576152.5B-
25S_2C_32301Fstreet_41577872.3B+
4S_1C_11105Fstreet_41596484.8B+
10S_1C_31301Mstreet_41616831.5B+
19S_2C_12105Mstreet_41708134.2A
6S_1C_21202Fstreet_41769463.5B-
29S_2C_32305Mstreet_41877348.9B
18S_2C_12104Fstreet_51599772.2B+
8S_1C_21204Fstreet_51626333.8B
26S_2C_32302Mstreet_51718832.7A
14S_1C_31305Fstreet_51876961.7B-
5S_1C_21201Mstreet_51886897.0A-
20S_2C_22201Mstreet_519310039.1B
32S_2C_42403Fstreet_61586059.7B+
7S_1C_21203Mstreet_61605358.8A+
16S_2C_12102Fstreet_61616150.6B+
28S_2C_32304Fstreet_61648195.5A-
9S_1C_21205Fstreet_61676368.4B-
34S_2C_42405Fstreet_61935447.6B
31S_2C_42402Mstreet_71668248.7B
15S_2C_12101Mstreet_71748483.3C
24S_2C_22205Fstreet_71837685.4B
12S_1C_31303Mstreet_71888249.7B
27S_2C_32303Fstreet_71909965.9C
21S_2C_22202Fstreet_71947768.5B+

五、问题与练习

1. 问题

【问题一】 在常用函数一节中,由于一些函数的功能比较简单,因此没有列入,现在将它们列在下面,请分别说明它们的用途并尝试使用。
sum/mean/median/mad/min/max/abs/std/var/quantile/cummax/cumsum/cumprod
和/平均值/中位数/平均值偏差/最小/最大/绝对值/标准差/方差/分位数/累计最大值/累计和/累计乘
【问题二】 df.mean(axis=1)是什么意思?它与df.mean()的结果一样吗?第一问提到的函数也有axis参数吗?怎么使用?
对每行取平均值,df.mean()取列平均值(默认axis=0),第一问的函数也有axis参数,axis=0对列运算,axis=1对行运算

2. 练习

【练习一】 现有一份关于美剧《权力的游戏》剧本的数据集,请解决以下问题:
(a)在所有的数据中,一共出现了多少人物? 564
(b)以单元格计数(即简单把一个单元格视作一句),谁说了最多的话? tyrion lannister 1760句
(c)以单词计数,谁说了最多的单词?
data=pd.read_csv('data/Game_of_Thrones_Script.csv')
N=data['Name'].nunique()
data['Name'].value_counts()
data['Name'].describe()
data['words']=data['Sentence'].map(lambda x:len(x.split(' ')))   #每句单词数
words1=data.groupby('Name')['words'].sum()  #通过Name分组求words列的和并输出series,(1)
words2=data.groupby('Name').sum()   #数据框对列求和,返回dataframe   (2)type(words)
words1
Name
a voice             5
addam marbrand      9
aemon             615
aeron             161
aerson             45... 
young hodor        87
young lyanna       26
young man          19
young ned          48
young rodrik        5
Name: words, Length: 564, dtype: int64
words1[words==26009]  #(1)
words2[words2['words']==26009]  #(2)
words
Name
tyrion lannister26009
【练习二】现有一份关于科比的投篮数据集,请解决如下问题:
(a)哪种action_type和combined_shot_type的组合是最多的?
(b)在所有被记录的game_id中,遭遇到最多的opponent是一个支?
data=pd.read_csv('data/Kobe_data.csv',index_col='shot_id')
data
#index_col的作用是将某一列作为行索引
action_typecombined_shot_typegame_event_idgame_idlatloc_xloc_ylonminutes_remainingperiod...shot_made_flagshot_typeshot_zone_areashot_zone_basicshot_zone_rangeteam_idteam_namegame_datematchupopponent
shot_id
1Jump ShotJump Shot102000001233.972316772-118.1028101...NaN2PT Field GoalRight Side(R)Mid-Range16-24 ft.1610612747Los Angeles Lakers2000/10/31LAL @ PORPOR
2Jump ShotJump Shot122000001234.0443-1570-118.4268101...0.02PT Field GoalLeft Side(L)Mid-Range8-16 ft.1610612747Los Angeles Lakers2000/10/31LAL @ PORPOR
3Jump ShotJump Shot352000001233.9093-101135-118.370871...1.02PT Field GoalLeft Side Center(LC)Mid-Range16-24 ft.1610612747Los Angeles Lakers2000/10/31LAL @ PORPOR
4Jump ShotJump Shot432000001233.8693138175-118.131861...0.02PT Field GoalRight Side Center(RC)Mid-Range16-24 ft.1610612747Los Angeles Lakers2000/10/31LAL @ PORPOR
5Driving Dunk ShotDunk1552000001234.044300-118.269862...1.02PT Field GoalCenter(C)Restricted AreaLess Than 8 ft.1610612747Los Angeles Lakers2000/10/31LAL @ PORPOR
..................................................................
30693Jump ShotJump Shot3974990008833.9963148-118.268864...0.02PT Field GoalCenter(C)In The Paint (Non-RA)Less Than 8 ft.1610612747Los Angeles Lakers2000/6/19LAL vs. INDIND
30694Tip ShotTip Shot3984990008834.044300-118.269864...NaN2PT Field GoalCenter(C)Restricted AreaLess Than 8 ft.1610612747Los Angeles Lakers2000/6/19LAL vs. INDIND
30695Running Jump ShotJump Shot4264990008833.8783-134166-118.403834...1.02PT Field GoalLeft Side Center(LC)Mid-Range16-24 ft.1610612747Los Angeles Lakers2000/6/19LAL vs. INDIND
30696Jump ShotJump Shot4484990008833.777331267-118.238824...0.03PT Field GoalCenter(C)Above the Break 324+ ft.1610612747Los Angeles Lakers2000/6/19LAL vs. INDIND
30697Jump ShotJump Shot4714990008833.9723172-118.268804...0.02PT Field GoalCenter(C)In The Paint (Non-RA)Less Than 8 ft.1610612747Los Angeles Lakers2000/6/19LAL vs. INDIND

30697 rows × 24 columns

uni=data.groupby('action_type')['combined_shot_type'].value_counts()
uni.max()
18880
uni.idxmax()
('Jump Shot', 'Jump Shot')
pd.Series(list(list(zip(*(pd.Series(list(zip(data['game_id'],data['opponent']))).unique()).tolist()))[1])).value_counts().index[0]
'SAS'

http://www.xdnf.cn/news/841303.html

相关文章:

  • 男生诡异世界观,是不是跟你想的不一样~
  • android led hal实践
  • 免费在线客服软件推荐:经济实用的客户沟通解决方案
  • 这个问题怎么解决?
  • 推荐:轻量级HEVC图像编码器——HEVC-image-encoder-lite
  • 基于ssm网上医院预约挂号系统+jsp论文
  • 【web前端开发网页设计】一步步实现:HTML + CSS + JavaScript 完整vue+elementui 个人资料(超实用)轻松搞定编辑保存:完整源代码与详细教程(新手必看)轻松入门前端开
  • ave2
  • 计算机中丢失atl80,atl80.dll丢失了怎么办-atl80.dll丢失的解决方法 - 河东软件园
  • 解决Win7的一个毛病——睡眠失效(只关闭显示器,不关主机)
  • 提交到YAHOO人工分类目录和开放式目录
  • 4. 2019年《斯坦福大学CS330多任务和元学习》第4讲:非参数元学习【中文字幕】
  • co作为前缀的意思_20个最常用的英语必备前缀!超实用!所有英语学习者必背...
  • 最全的免费OA试用地址
  • NVIDIA发布Tegra 4:四核A15+72核心GPU
  • Win7如何简单的关闭445端口及445端口入侵详解
  • 2018第九届蓝桥杯JavaC组省赛真题详解
  • 上海帖易之易度文档管理
  • 不容错过的5大化学试剂购买网站,确定不来看看?
  • 详解机器学习中的熵、联合熵、条件熵、相对熵和交叉熵
  • 30s带你了解 #!/bin/bash
  • Linux一句话精彩问答
  • Pro-Level Photography for Graphic Designers 平面设计师专业摄影教程 Lynda课程中文字幕
  • 运维 | 四层和七层负载均衡介绍
  • vi快捷键
  • 华为鲲鹏题库(三)
  • C语言学生管理系统
  • Python实战 | 如何使用 Python 调用 API
  • 外国电影字幕翻译,怎么把英文字幕翻译成中文字幕?
  • english joke,and some notes for english study