codestates / codestates/ds-blog

[최근후] day 4 advanced To-Do (데이터 시각화 시도)

Open
#51 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
2
Forks
4
PR merge metrics
No merged PRs in 30d

Description

## 난 rate를 구해서 알아보기 쉽게 만들고 싶은데 아직은 어떻게 하는지 모르겟다...!

```py
# 타이타닉 데이터 불러오기
import pandas as pd
titanic = pd.read_csv('https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv')
titanic.head()
```
```py
# 생존자들만 보기
survived = titanic[titanic["Survived"]==1]
survived
```
```py
# 남자 생존자 vs 희생자
titanic[titanic.Sex=='male'].Survived.value_counts().plot(kind='barh', title='Male Survived')
```
![image](https://user-images.githubusercontent.com/61172021/92088980-91b61600-ee08-11ea-9549-a254ea2694e0.png)
```py
# 여자 생존자 vs 희생자
titanic[titanic.Sex=='female'].Survived.value_counts().plot(kind='barh', title='Female Survived')
```
![image](https://user-images.githubusercontent.com/61172021/92089163-be6a2d80-ee08-11ea-9b57-14981b8a1228.png)
**위의 두 그래프를 보면 여자는 생존자가 희생자보다 많지만 남자는 희생자가 생존자보다 많다. 이 데이터를 더 알아보기쉽게 만드는 방법을 알아봐야겠다 ㅎㅎ 아래에 있는 그래프들도 모두 두가지로 보여지는데 마찬가지다....!**
```py
# 전체 탑승자들의 연령 그래프
titanic['Age'].hist()
```
![image](https://user-images.githubusercontent.com/61172021/92089255-db9efc00-ee08-11ea-9b1b-bd16f766c032.png)
```py
# 생존자들의 연령 그래프
survived['Age'].hist()
```
![image](https://user-images.githubusercontent.com/61172021/92089302-efe2f900-ee08-11ea-8b3b-31fac22ed921.png)
**위에 말했듯이 이것들을 더 이해하기쉽게 보기위해선 이 두 그래프가 동시에 보여져야 할것같다.**
```py
# 전체 탑승자들의 class
titanic.groupby("Pclass")["Pclass"].count().plot(kind='barh', title='People by class')
```
![image](https://user-images.githubusercontent.com/61172021/92089368-06895000-ee09-11ea-812a-d242b4697f84.png)
```py
# 생존자들의 class
survived.groupby("Pclass")["Pclass"].count().plot(kind='barh', title='People Survived by class')
```
![image](https://user-images.githubusercontent.com/61172021/92089416-16a12f80-ee09-11ea-857c-1b1211070f73.png)
**전체 탑승자를 보면 class 3 에 탑승한 사람들이 다른 두클래스에 비해 2배이상 많지만 생존자는 그렇지 않다..!**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.