본문 바로가기

전체 글732

pandas 판다스 기초 14 import excel # Importing From Excel Files with pd.read_excel() ## First Steps - NEW (from Pandas Version 0.24x) import pandas as pd sales = pd.read_excel('sales.xls') sales ''' Unnamed: 0CityCountrySalesBonus 0MikeNew YorkUSA252.50 1JimBostonUSA434.30 2StevenLondonUK767.60 3JoeMadridSpain121.80 4TomParisFrance8913.35 ''' # index_col을 통해서 엑셀을 열어봤을때 첫번째 컬럼을 열게된다. - index_col = 0 sales = pd.read_excel('sales.xl.. 2022. 7. 27.
pandas 판다스 기초 13 import CSV file # Importing CSV Files ## First Steps with open('titanic.csv') as f: text = f.readlines() text ''' ['survived,pclass,sex,age,sibsp,parch,fare,embarked,deck\n', '0,3,male,22.0,1,0,7.25,S,\n', '1,1,female,38.0,1,0,71.2833,C,C\n', '1,3,female,26.0,0,0,7.925,S,\n', '1,1,female,35.0,1,0,53.1,S,C\n', '0,3,male,35.0,0,0,8.05,S,\n', '0,3,male,,0,0,8.4583,Q,\n', ''' # 같은게 배열된다. len(text) # 892 # pandas의 r.. 2022. 7. 26.
pandas 틀린부분 복기 6 matplotlib # 문제1 # Create the graph below (lineplot for all numerical columns)! # subplots, sharex에 대한 기능이 생각이 안났었다. cars.plot(figsize = (14,10), subplots = True, sharex = False) plt.show() # 문제2 # Create the graph below (Scatterplot with horsepower and mpg)! Fill in the gaps! # 내 코드 cars.plot(kind = 'scatter', x = 'horsepower', y = 'mpg', figsize = (12,10), c = 'cylinders', marker = 'x', colormap = "virid.. 2022. 7. 26.
pandas 판다스 기초 12 Matplotlib 이번 파트는 정말정말 중요한 부분중에 하나라고 본다. # The plot() method import pandas as pd titanic = pd.read_csv('titanic.csv') titanic.info() ''' RangeIndex: 891 entries, 0 to 890 Data columns (total 9 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 survived 891 non-null int64 1 pclass 891 non-null int64 2 sex 891 non-null object 3 age 714 non-null float64 4 sibsp 891 non-null int64 5 parc.. 2022. 7. 26.