![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 57
Demi 丫
做一只漂亮的程序媛
展开
-
Pandas DataFrame 多层索引如何取值,索引与列如何转换
首先讲讲根据行列索引的查询import pandas as pdimport numpy as npdf = pd.DataFrame(np.random.randint(50, 100, size=(4, 4)), columns=pd.MultiIndex.from_product( [['math', 'physics'], ['term1', 'term2']]), index=pd.Mul原创 2021-03-14 15:01:48 · 11729 阅读 · 2 评论 -
Pandas中loc和iloc函数用法总结, 以及如何在groupBy后提取分组的指定行数据
loc函数:通过行索引 “Index” 中的具体值来取行数据(如取"Index"为"A"的行)iloc函数: 通过行号来取行数据(如取第二行的数据)1. 利用loc、iloc提取行数据import numpy as npimport pandas as pd#创建一个Dataframedata=pd.DataFrame(np.arange(16).reshape(4,4),index=list('abcd'),columns=list('ABCD')) In[1]: dataOut[1]:原创 2021-03-14 12:15:08 · 5795 阅读 · 0 评论 -
python中的*args和**kwargs
*args和**kwargs 是python中的可变参数。*args表示任何多个无名参数,它是一个tuple;**kwargs表示关键字参数,它是一个 dict。并且同时使用*args和**kwargs时,*args参数列必须要在**kwargs前,像foo(a=1, b='2', c=3, a', 1, None, )这样调用的话,会提示语法错误“SyntaxError: non-keyword...原创 2019-01-10 20:02:30 · 117 阅读 · 0 评论