第2次作业-titanic数据集练习
2024-08-30 20:18:26
一、读入titanic.xlsx文件,按照教材示例步骤,完成数据清洗。
titanic数据集包含11个特征,分别是:
Survived:0代表死亡,1代表存活
Pclass:乘客所持票类,有三种值(1,2,3)
Name:乘客姓名
Sex:乘客性别
Age:乘客年龄(有缺失)
SibSp:乘客兄弟姐妹/配偶的个数(整数值)
Parch:乘客父母/孩子的个数(整数值)
Ticket:票号(字符串)
Fare:乘客所持票的价格(浮点数,0-500不等)
Cabin:乘客所在船舱(有缺失)
Embark:乘客登船港口:S、C、Q(有缺失)
import pandas as pd
titanic = pd.read_excel('titanic (1).xlsx')
titanic.head()
二、对titanic数据集完成以下统计操作
1.统计乘客死亡和存活人数
titanic['survived'].value_counts()
2.统计乘客中男女性别人数
titanic['sex'].value_counts()
3.统计男女获救的人数
4.统计乘客所在的船舱等级的人数
titanic['class'].value_counts()
5.使用corr()函数,判断两个属性是否具有相关性,分析舱位的高低和存活率的关系
titanic['survived'].corr(titanic['pclass'])
6.画出乘客票价与舱位等级的箱体图Boxplot,从图中能够得到哪些结论?
titanic.boxplot(column=['fare'],by=['pclass'],grid=False)
最新文章
- 使用Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境(二)
- sassCore
- 浅析手机抓包方法实践(zt)
- Leetcode: Assign Cookies
- python面向对象编程(上)
- 通过store为toolbar添加按钮
- UIView和CALayer有什么关系
- Swift继承的用法
- 【论文:麦克风阵列增强】Signal Enhancement Using Beamforming and Nonstationarity with Applications to Speech
- Mysql之单表记录查询
- Windows phone 8.1之数据绑定(Data Binding)
- [Swift]LeetCode845. 数组中的最长山脉 | Longest Mountain in Array
- 实验楼-Git实战教程
- Linux Performance tool
- 又一个opengl教程,多多益善
- Google工作原理
- 增加centos7.3上安装php7的php-soap扩展
- ZooKeeper常见问题
- 替换换行符:回车换行CR/LF
- gdi+ 中发生一般性错误 wpf解决方法
热门文章
- 学习ES6笔记──工作中常用到的ES6语法
- DefinePlugin插件用法
- Java逆向之UML查看工具(检索记录)
- spf13-vim 显示neocomplete requires ...th Lua support
- Supermap/Cesium 开发心得----定位
- cesium计算当前地图范围extent以及近似当前层级zoom
- 《老师说的都对》- Alpha冲刺阶段博客目录
- oop面向对象【类与对象、封装、构造方法】
- linux bash变量作用域
- DiskCatalogMaker for Mac常见问题解答