北京 |深度学习与人工智能研修
12月23-24日

再设经典课程   重温深度学习
阅读全文
>

计算操作

1、pandas.series.value_counts

Series.value_counts(normalize=False,sort=True,ascending=False, bins=None, dropna=True)

作用:返回一个包含值和该值出现次数的Series对象,次序按照出现的频率由高到低排序.

参数: 
normalize : 布尔值,默认为False,如果是True的话,就会包含该值出现次数的频率. 
sort : 布尔值,默认为True.排序控制. 
ascending : 布尔值,默认为False,以升序排序 
bins : integer, optional 
Rather than count values, group them into half-open bins, a convenience for pd.cut, only works with numeric data 
dropna : 布尔型,默认为True,表示不包括NaN

2.pandas.DataFrame.count

DataFrame.count(axis=0, level=None, numeric_only=False) 
Return Series with number of non-NA/null observations over requested axis. Works with non-floating point data as well (detects NaN and None)

Parameters: 
axis : {0 or ‘index’, 1 or ‘columns’}, default 0 
0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise 
level : int or level name, default None 
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a DataFrame 
numeric_only : boolean, default False 
Include only float, int, boolean data 
Returns: 
count : Series (or DataFrame if level specified)

最大最小值

标准统计函数

pandas.dataframe.sum

返回指定轴上值的和.

DataFrame.sum(axis=None, skipna=None, level=None, numeric_only=None, **kwargs)

参数: 
axis : {index (0), columns (1)} 
skipna : 布尔值,默认为True.表示跳过NaN值.如果整行/列都是NaN,那么结果也就是NaN 
level : int or level name, default None 
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series 
numeric_only : boolean, default None 
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series. 
Returns: 
sum : Series or DataFrame (if level specified)

import numpy as np

import pandas as pd

df=pd.DataFrame(data=[[1.4,np.nan],[7.1,-4.5],[np.nan,np.nan],[0.75,-1.3]],                index=["a","b","c","d"],

columns=["one","two"])

print("df:")

print(df)

#直接使用sum()方法,返回一个列求和的Series,自动跳过NaN值

print("df.sum()")

print(df.sum())

#当轴为1.就会按行求和

print("df.sum(axis=1)")

print(df.sum(axis=1))

#选择skipna=False可以禁用跳过Nan值

print("df.sum(axis=1,skipna=False):")

print(df.sum(axis=1,skipna=False))

结果: 

2、pandas.dataframe.mean

返回指定轴上值的平均数.

DataFrame.mean(axis=None,skipna=None,level=None,numeric_only=None, **kwargs)

参数: 
axis : {index (0), columns (1)} 
skipna :布尔值,默认为True.表示跳过NaN值.如果整行/列都是NaN,那么结果也就是NaN 
level : int or level name, default None 
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series 
numeric_only : boolean, default None 
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.

例子:

import numpy as np

import pandas as pd

df=pd.DataFrame(data=[[1.4,np.nan],[7.1,-4.5],[np.nan,np.nan],[0.75,-1.3]],                
index=["a","b","c","d"],

columns=["one","two"])

print("df:")

print(df)

#直接使用mean()方法,返回一个列求平均数的Series,自动跳过NaN值

print("df.mean()")

print(df.mean())

#当轴为1.就会按行求平均数

print("df.mean(axis=1)")

print(df.mean(axis=1))

#选择skipna=False可以禁用跳过Nan值

print("df.mean(axis=1,skipna=False):")

print(df.mean(axis=1,skipna=False))

结果: 

排序

1、pandas.dataframe.sort_values

DataFrame.sort_values(by,axis=0,ascending=True,inplace=False, kind='quicksort', na_position='last')

Sort by the values along either axis

参数: 
by : str or list of str 
Name or list of names which refer to the axis items. 
axis : {0 or ‘index’, 1 or ‘columns’}, default 0 
Axis to direct sorting 
ascending : bool or list of bool, default True 
Sort ascending vs. descending. Specify list for multiple sort orders. If this is a list of bools, must match the length of the by. 
inplace : bool, default False 
if True, perform operation in-place 
kind : {‘quicksort’, ‘mergesort’, ‘heapsort’}, default ‘quicksort’ 
Choice of sorting algorithm. See also ndarray.np.sort for more information. mergesort is the only stable algorithm. For DataFrames, this option is only applied when sorting on a single column or label. 
na_position : {‘first’, ‘last’}, default ‘last’ 
first puts NaNs at the beginning, last puts NaNs at the end 
Returns: 
sorted_obj : DataFrame

原文链接:http://blog.csdn.net/xierhacker/article/details/65644734

查阅更为简洁方便的分类文章以及最新的课程、产品信息,请移步至全新呈现的“LeadAI学院官网”:

www.leadai.org

请关注人工智能LeadAI公众号,查看更多专业文章

大家都在看


LSTM模型在问答系统中的应用

基于TensorFlow的神经网络解决用户流失概览问题

最全常见算法工程师面试题目整理(一)

最全常见算法工程师面试题目整理(二)

TensorFlow从1到2 | 第三章 深度学习革命的开端:卷积神经网络

装饰器 | Python高级编程

今天不如来复习下Python基础


点击“阅读原文”直接打开报名链接

Python数据分析模块 | pandas做数据分析(三):统计相关函数相关推荐

  1. Python数据分析模块 | pandas做数据分析(二):常用预处理操作

    北京 | 深度学习与人工智能研修 12月23-24日 再设经典课程  重温深度学习 阅读全文 > 在数据分析和机器学习的一些任务里面,对于数据集的某些列或者行丢弃,以及数据集之间的合并操作是非常 ...

  2. Python数据分析模块 | pandas做数据分析(一):基本数据对象

    北京 | 深度学习与人工智能研修 12月23-24日 再设经典课程  重温深度学习 阅读全文 > 正文共3017个字 4张图,预计阅读时间:18分钟. pandas有两个最主要的数据结构,分别是 ...

  3. 这十套练习,教你如何用Pandas做数据分析

    最新工作比较忙,python这块搁置了好久都没有好好学习以及更新相关学习笔记,立下flag,争取两天更新一个练习题,到十一月初更新完这块内容 练习1-开始了解你的数据(2021-11-02已完成) 练 ...

  4. c++输出txt格式循环一组数据后换行再循环一次_numpy、pandas以及用pandas做数据分析的案例...

    本文也是秦路老师python教程的学习笔记.这篇也是发给超哥看的:很多人说python很简单很好学,也有很多人说python没有java和c的功能强大.但是这都不重要,重要的是我们想学了,想画图也好做 ...

  5. 【转】数据运营经验:什么是数据分析?怎么做数据分析?

    那到底什么是数据分析呢? 说说数据哥的理解:数据分析是基于商业目的,有目的的进行收集.整理.加工和分析数据,提炼有价信息的一个过程. 其过程概括起来主要包括:明确分析目的与框架.数据收集.数据处理.数 ...

  6. csv 20位数据 如何打开可以预览完整数字_干货Python Pandas 做数据分析之玩转 Excel 报表分析...

    本篇文章选自作者在 GitChat 的分享,若有什么问题,可在公众号回复「小助手」添加小助手微信,邀请你进入技术交流群. 各位朋友大家好,非常荣幸和大家聊一聊用 Python Pandas 处理 Ex ...

  7. pandas 取excel 中的某一列_干货Python Pandas 做数据分析之玩转 Excel 报表分析

    本篇文章选自作者在 GitChat 的分享,若有什么问题,可在公众号回复「小助手」添加小助手微信,邀请你进入技术交流群. 各位朋友大家好,非常荣幸和大家聊一聊用 Python Pandas 处理 Ex ...

  8. Python Pandas 做数据分析之玩转 Excel 报表分析

    各位朋友大家好,非常荣幸和大家聊一聊用 Python Pandas 处理 Excel 数据的话题.因为工作中一直在用 Pandas,所以积累了一些小技巧,在此借 GitChat 平台和大家分享一下心得 ...

  9. python计算两组数据的协方差_(python3)数据分析之Pandas:汇总、统计、相关系数和协方差...

    pandas对象中拥有一组常用的数学和统计方法,跟NumPy数组相比,它们是基于没有缺失数据的加上构建的. In [71]: df = DataFrame([[1.4,np.nan],[7.1,-4. ...

最新文章

  1. Linux下的Shell编程(2)环境变量和局部变量
  2. 干货丨手把手带你玩转机器学习和深度学习
  3. Qt中QAbstractTableModel、QItemDelegate的联合使用
  4. CONVERT_DATE_WITH_THRESHOLD
  5. 谨慎Asp.net中static变量的用法
  6. drive es 软件兼容_某知名软件被完美修改!对不住了!
  7. Linux io运行情况,Linux IO调度层分析
  8. 2021-09-19SQL42,SQL44,SQL45
  9. crx文件里面的html文件,javascript – Chrome扩展程序:在crx文件中打开html,标签上没有图标...
  10. Python 爬虫从入门到进阶之路(四)
  11. 使用 Shell (命令备忘)
  12. Arp病毒专杀工具下载及其防治解决方案
  13. 网络检测之(MTR WinMTR )网络链路追踪公路
  14. 按键精灵取html,PC按键精灵 JSON解析
  15. c语言flag什么意思,立flag是什么意思flag是什么?立flag用语出处和使用方法
  16. 以太网协议 | ARP协议详解-ARP报文结构解析
  17. Google Drive 转存别人分享的文件到自己的网盘
  18. 软件调试高级研习班庐山秀峰站(2017-06)
  19. Altium Designer绘制PCB板子的基本步骤
  20. 天下无云第二步,逐像素图片合成

热门文章

  1. dd实现Linux转移,linux命令-dd {拷贝并替换}
  2. mysql 时间段在不在另外的时间段中_你知道自来水一天中哪个时间段最脏、最具毒性吗?记住这几点避开致命自来水...
  3. 【Linux】Docker 基础与实战,看这一篇就够了
  4. 如何设置mysql让其他人能访问_怎么设置MySQL就能让别人访问本机的数据库了?...
  5. NBU调用crontab备份
  6. default.html文件,default.html
  7. oracle查询访问记录,[原创]Oracle Spatial新驱动的查询记录实例
  8. linux DTS介绍
  9. Python高级编程(三)
  10. java启动项目报错,org.apache.catalina.lifecycleException..............以及解决方案