https://www.datamanim.com/dataset/03_dataq/typeone.html#id6
작업 1유형 — DataManim
Question 각 비디오는 10분 간격으로 구독자수, 좋아요, 싫어요수, 댓글수가 수집된것으로 알려졌다. 공범 EP1의 비디오정보 데이터중 수집간격이 5분 이하, 20분이상인 데이터 구간( 해당 시점 전,후
www.datamanim.com
Question
Legendary 컬럼은 전설포켓몬 유무를 나타낸다.전설포켓몬과 그렇지 않은 포켓몬들의 HP평균의 차이를 구하여라
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/Datamanim/datarepo/main/pok/Pokemon.csv')
df.head()
target = df.groupby('Legendary').mean()['HP']
target
target = df.groupby('Legendary').mean()['HP']
result = target.values[1] -target.values[0]
print(result)
Question
Type 1은 주속성 Type 2 는 부속성을 나타낸다. 가장 많은 부속성 종류는 무엇인가?
result = df['Type 2'].value_counts().index[0]
print(result)
Question
가장 많은 Type 1 의 종의 평균 Attack 을 평균 Defense로 나눈값은?
Max = df['Type 1'].value_counts().index[0]
result = df[df['Type 1']== Max].Attack.mean() /df[df['Type 1']== Max].Defense.mean()
print(result)
Question
포켓몬 세대(Generation) 중 가장많은 Legendary를 보유한 세대는 몇세대인가?
result =df[df.Legendary==True].Generation.value_counts().index[0]
result
Question
‘HP’, ‘Attack’, ‘Defense’, ‘Sp. Atk’, ‘Sp. Def’, ‘Speed’ 간의 상관 계수중 가장 절댓값이 큰 두 변수와 그 값을 구하여라
df[[ 'HP', 'Attack', 'Defense', 'Sp. Atk', 'Sp. Def', 'Speed']].corr().unstack().reset_index()
target = df[[ 'HP', 'Attack', 'Defense', 'Sp. Atk', 'Sp. Def', 'Speed']].corr().unstack().reset_index().rename(columns={0: "corr"})
result = target[target['corr']!=1].sort_values('corr',ascending=False).iloc[0]
print(result)
Question
각 Generation의 Attack으로 오름차순 정렬시 상위 3개 데이터들(18개)의 Attack의 전체 평균을 구하여라
df.sort_values(['Generation','Attack']).groupby('Generation').head(3)
result = df.sort_values(['Generation','Attack']).groupby('Generation').head(3).Attack.mean()
print(result)
Question
각 Generation의 Attack으로 내림차순 정렬시 상위 5개 데이터들(30개)의 Attack의 전체 평균을 구하여라
result = df.sort_values(['Generation','Attack'],ascending=False).groupby('Generation').head(5).Attack.mean()
print(result)
Question
가장 흔하게 발견되는 (Type1 , Type2) 의 쌍은 무엇인가?
df[['Type 1','Type 2']].value_counts()
result = df[['Type 1','Type 2']].value_counts().head(1)
print(result)
Question
한번씩만 존재하는 (Type1 , Type2)의 쌍의 갯수는 몇개인가?
target = df[['Type 1','Type 2']].value_counts()
result = len(target[target==1])
print(result)
Question
한번씩만 존재하는 (Type1 , Type2)의 쌍을 각 세대(Generation)은 각각 몇개씩 가지고 있는가?
target = df[['Type 1','Type 2']].value_counts()
target2 =target[target==1]
target2
target2.reset_index().values
target = df[['Type 1','Type 2']].value_counts()
target2 =target[target==1]
lst = []
for value in target2.reset_index().values:
t1 = value[0]
t2 = value[1]
sp = df[(df['Type 1']==t1) & (df['Type 2']==t2)]
lst.append(sp)
lst
target = df[['Type 1','Type 2']].value_counts()
target2 =target[target==1]
lst = []
for value in target2.reset_index().values:
t1 = value[0]
t2 = value[1]
sp = df[(df['Type 1']==t1) & (df['Type 2']==t2)]
lst.append(sp)
result = pd.concat(lst).reset_index(drop=True).Generation.value_counts().sort_index()
print(result)
'빅데이터분석기사 > 작업 1유형' 카테고리의 다른 글
기온 강수량 데이터 (0) | 2022.08.15 |
---|---|
대한민국 체력장 데이터 (0) | 2022.08.15 |
지역구 에너지 소비량 데이터 (0) | 2022.08.15 |
전세계 행복도 지표 데이터 (0) | 2022.08.15 |
서울시 따릉이 이용정보 데이터 (0) | 2022.08.15 |