1. 표를 불러옵니다

import seaborn as sns              # seaborn패키지에는 유명한 데이터 몇가지 있어서 불러와봤습니다
planets = sns.load_dataset('planets')              # planets라는 데이터셋 부르기

 

2. 데이터/컬럼 수 확인

planets.shape 

출력>
(1035, 6)

 

3. 대략의 표 확인

planets.head() 

출력>
method	number	orbital_period	mass	distance	year
0	Radial Velocity	1	269.300	7.10	77.40	2006
1	Radial Velocity	1	874.774	2.21	56.95	2008
2	Radial Velocity	1	763.000	2.60	19.84	2011
3	Radial Velocity	1	326.030	19.40	110.62	2007
4	Radial Velocity	1	516.220	10.50	119.47	2009

 

4. 데이터 정제 : NaN 데이터 제거 (혹은 mean으로 평균값을 내주는 방법도 있다)

.dropna : NaN 값이 있는 행또는 열을 제거할 수 있다. 기본적으로 axis=0으로 세팅되어있다.

planets.dropna()

출력>

method	number	orbital_period	mass	distance	year
0	Radial Velocity	1	269.30000	7.100	77.40	2006
1	Radial Velocity	1	874.77400	2.210	56.95	2008
2	Radial Velocity	1	763.00000	2.600	19.84	2011
3	Radial Velocity	1	326.03000	19.400	110.62	2007
4	Radial Velocity	1	516.22000	10.500	119.47	2009
...	...	...	...	...	...	...
640	Radial Velocity	1	111.70000	2.100	14.90	2009
641	Radial Velocity	1	5.05050	1.068	44.46	2013
642	Radial Velocity	1	311.28800	1.940	17.24	1999
649	Transit	1	2.70339	1.470	178.00	2013
784	Radial Velocity	3	580.00000	0.947	135.00	2012
498 rows × 6 columns

혹은 아래처럼 출력해서 봐도 된다

planets.dropna().describe()    # 빈값을 날린 후의 대략적표

출력>
	number	orbital_period	mass	distance	year
count	498.00000	498.000000	498.000000	498.000000	498.000000
mean	1.73494	835.778671	2.509320	52.068213	2007.377510
std	1.17572	1469.128259	3.636274	46.596041	4.167284
min	1.00000	1.328300	0.003600	1.350000	1989.000000
25%	1.00000	38.272250	0.212500	24.497500	2005.000000
50%	1.00000	357.000000	1.245000	39.940000	2009.000000
75%	2.00000	999.600000	2.867500	59.332500	2011.000000
max	6.00000	17337.500000	25.000000	354.000000	2014.000000

+ Recent posts