Skip to content
Snippets Groups Projects
Commit e6f3fecc authored by Young Woo Kim's avatar Young Woo Kim
Browse files

Upload New File

parent 9111e232
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
import pandas as pd
import numpy as np
```
%% Cell type:code id: tags:
``` python
data = {'name': ['YoungWoo', 'DomgHo', 'Minsu', 'Hong', 'Kwangsung'],
'year': [2013, 2014, 2015, 2016, 2015],
'points': [1.5, 1.7, 3.6, 2.4, 2.9]}
df = pd.DataFrame(data)
print (df)
```
%% Output
name year points
0 YoungWoo 2013 1.5
1 DomgHo 2014 1.7
2 Minsu 2015 3.6
3 Hong 2016 2.4
4 Kwangsung 2015 2.9
%% Cell type:code id: tags:
``` python
df
```
%% Output
name year points
0 YoungWoo 2013 1.5
1 DomgHo 2014 1.7
2 Minsu 2015 3.6
3 Hong 2016 2.4
4 Kwangsung 2015 2.9
%% Cell type:code id: tags:
``` python
csv = pd.read_csv('C:/Users/김영우/jupyter/example.csv')
csv
```
%% Output
ID NAME 나이 점수
0 1 Kim 23 75
1 2 Lee 19 80
2 3 Choi 20 59
3 4 Song 23 90
4 5 Hwang 25 83
%% Cell type:code id: tags:
``` python
print (df.columns)
print (csv.columns)
```
%% Output
Index(['name', 'year', 'points'], dtype='object')
Index(['ID', 'NAME', '나이', '점수'], dtype='object')
%% Cell type:code id: tags:
``` python
print (df.values)
print (csv.values)
```
%% Output
[['YoungWoo' 2013 1.5]
['DomgHo' 2014 1.7]
['Minsu' 2015 3.6]
['Hong' 2016 2.4]
['Kwangsung' 2015 2.9]]
[[1 'Kim' 23 75]
[2 'Lee' 19 80]
[3 'Choi' 20 59]
[4 'Song' 23 90]
[5 'Hwang' 25 83]]
%% Cell type:code id: tags:
``` python
df.describe()
```
%% Output
year points
count 5.000000 5.000000
mean 2014.600000 2.420000
std 1.140175 0.864292
min 2013.000000 1.500000
25% 2014.000000 1.700000
50% 2015.000000 2.400000
75% 2015.000000 2.900000
max 2016.000000 3.600000
%% Cell type:code id: tags:
``` python
csv.describe()
```
%% Output
ID 나이 점수
count 5.000000 5.00000 5.000000
mean 3.000000 22.00000 77.400000
std 1.581139 2.44949 11.631853
min 1.000000 19.00000 59.000000
25% 2.000000 20.00000 75.000000
50% 3.000000 23.00000 80.000000
75% 4.000000 23.00000 83.000000
max 5.000000 25.00000 90.000000
%% Cell type:code id: tags:
``` python
df['zero'] = np.zeros(5)
df
```
%% Output
name year points zero
0 YoungWoo 2013 1.5 0.0
1 DomgHo 2014 1.7 0.0
2 Minsu 2015 3.6 0.0
3 Hong 2016 2.4 0.0
4 Kwangsung 2015 2.9 0.0
%% Cell type:code id: tags:
``` python
csv['random'] = np.random.rand(5)
csv['random'] *= 10
csv
```
%% Output
ID NAME 나이 점수 random
0 1 Kim 23 75 1.859625
1 2 Lee 19 80 0.588391
2 3 Choi 20 59 8.702442
3 4 Song 23 90 7.638486
4 5 Hwang 25 83 9.592227
%% Cell type:code id: tags:
``` python
del df['zero']
df
```
%% Output
name year points
0 YoungWoo 2013 1.5
1 DomgHo 2014 1.7
2 Minsu 2015 3.6
3 Hong 2016 2.4
4 Kwangsung 2015 2.9
%% Cell type:code id: tags:
``` python
val = pd.Series([10, 20, 30, 40, 50])
df['tens'] = val
df
```
%% Output
name year points tens
0 YoungWoo 2013 1.5 10
1 DomgHo 2014 1.7 20
2 Minsu 2015 3.6 30
3 Hong 2016 2.4 40
4 Kwangsung 2015 2.9 50
%% Cell type:code id: tags:
``` python
print (df.sum(axis = 0))
print (df.sum(axis = 1))
print (df.min(axis = 0))
```
%% Output
name YoungWooDomgHoMinsuHongKwangsung
year 10073
points 12.1
tens 150
dtype: object
0 2024.5
1 2035.7
2 2048.6
3 2058.4
4 2067.9
dtype: float64
name DomgHo
year 2013
points 1.5
tens 10
dtype: object
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment