달력

1

« 2020/1 »

  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  


 

 

기초 통계분석 함수 - R vs Python

 

구분

R 함수

Python

 

import numpy as np

데이터 갯수

# 벡터의 길이

length(x)

 

# dataframe의 행과 열의 개수

dim(x)

 

 

# dataframe의 행의 수

nrow(x)

 

# column()의 개수, 즉 변수의 개수

ncol(x)

 

·       np.len(x)

표본 평균

·       mean()

·       np.mean()

표본 분산

·       var()

·       np.var()

표준 편차

·       sd()

·       np.std()

다섯 수치 요약

·       fivenum()

·       # 최소값

·       np.percentile(x, 0))

 

·       # 1사분위

·       np.percentile(x, 25)

 

·       # 2사분위

·       np.percentile(x, 50)

 

·       # 3사분위

·       np.percentile(x, 75)

 

·       # 4사분위 (최댓값)

·       np.percentile(x, 100)

최빈값

·       which.max( table() )

·       np.argmax()

기술 통계

·       head()

·       summary()

·       describe{Hmisc}

·       summary.formula{Hmisc}

·       {SciPy} describe()

회귀분석

·       lm()

·       {sklearn} LogisticRegression()

 

 


Posted by codedragon codedragon

댓글을 달아 주세요

2020. 1. 27. 00:30

swapaxes() Development/Python

 

 

 

swapaxes()

·       T 좀 더 일반화된 버전으로 파라미터로 전달하는 2개의 축을 서로 바꿔서 다차원 배열을 전치합니다.

·       2차원 배열에 0번과 1번 축을 파라미터로 전달하는 것은 배열을 전치하는 것과 같습니다.

 

 

 

2 차원에서의 축 번호

2차원

 

 

Python

0

1

R

1

2

 

 

 

 

3 차원에서의 축 번호     

3차원

Python

0

1

2

R

3

1

2

 

 


Posted by codedragon codedragon

댓글을 달아 주세요


 

 

numpy 배열의 속성

·       numpy에서 배열은 동일한 타입의 값들을 가집니다.

·       numpy 배열의 차원을 ndim 라 하고, 각 차원의 크기를 튜플로 표시하는 것을 shape 라고 합니다.

 

구분

설명

np.array([[0, 1, 2], [3, 4, 5]])

2차원 배열

 

# 행이 2이고 열이 3 2차원 배열

ndim

배열의 차원

 

# 2

shape

배열의 크기, 모양

배열의 구조를 파이썬 튜플 자료형

 

(, )

# (2, 3)

dtype

데이터 타입

 

# int

 

 


Posted by codedragon codedragon

댓글을 달아 주세요

2020. 1. 25. 12:32

apply() 적용 Development/Python


 

 

apply() 적용

·         행이나 단위로 복잡한 처리를 하고 싶을 사용합니다.

·         apply() 인수로 또는 열을 넣으면 (또는 ) 반복하여 해당 함수를 적용시킵니다.

 

method

description

apply(|열을 받는 함수, axis=0)

인수로 또는 열을 넣으면 (또는 ) 반복하여 해당 함수를 적용시킵니다.

apply(pd.value_counts)

열에 대해 어떤 값이 얼마나 사용되었는지 알려줍니다.

 

 


Posted by codedragon codedragon

댓글을 달아 주세요



 

 

일반 함수 vs 익명함수

 

구분

def  이름이 있는 함수 정의

lambda  익명 함수 정의

함수 정의

def my_2times(x):

     result = x*2

     return result

 

my_2times = lambda x: x*2

 

 

 

함수 호출

my_2times(3)

# 6

my_2times(3)

# 6

 

 



Posted by codedragon codedragon

댓글을 달아 주세요



 

 

 

mlxtend 설치시 에러

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied

[WinError 5] Access is denied: 'c:\\python\\python36\\lib\\site-packages\\~umpy\\.libs\\libopenblas.BNVRK7633HSX7YVO2TADGR4A5KEKXJAW.gfortran-win_amd64.dll'

Consider using the `--user` option or check the permissions.

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\python\\python36\\lib\\site-packages\\~andas\\io\\msgpack\\_packer.cp36-win_amd64.pyd'

Consider using the `--user` option or check the permissions.

 

 

 

 

해결방법

numpy, scipy, joblib, pandas, matplotlib, scikit-learn, mlxtend 함께 사용되는 해당 패키지 버전이 맞지 않아 에러가 발생하며

반복적으로 명령어를 수행하면 이전 패키지를 삭제 다시 설치해 주는 작업을 해주므로 에러가 나오지 않을 때까지 반복 줍니다.

 

C:\CodeLab>

 

C:\CodeLab>pip install mlxtend

Collecting mlxtend

  Downloading https://files.pythonhosted.org/packages/52/04/c362f34f666f0ddc7cf593805e64d64fa670ed96fd9302e68549dd48287d/mlxtend-0.17.0-py2.py3-none-any.whl (1.3MB)

     |████████████████████████████████| 1.3MB 252kB/s

Requirement already satisfied: setuptools in c:\python\python36\lib\site-packages (from mlxtend) (39.0.1)

Collecting scipy>=1.2.1

  Downloading https://files.pythonhosted.org/packages/8d/2f/fcb6150813b89d628749784370132e431f687ebab5a1063eb298cc941f76/scipy-1.4.1-cp36-cp36m-win_amd64.whl (30.8MB)

     |████████████████████████████████| 30.8MB 177kB/s

Collecting joblib>=0.13.2

  Downloading https://files.pythonhosted.org/packages/28/5c/cf6a2b65a321c4a209efcdf64c2689efae2cb62661f8f6f4bb28547cf1bf/joblib-0.14.1-py2.py3-none-any.whl (294kB)

     |████████████████████████████████| 296kB 145kB/s

Collecting numpy>=1.16.2

  Downloading https://files.pythonhosted.org/packages/53/74/b997e4c7b4abc668e99f4c3dba87ee2c6f7559319af756cc1ede37665a8d/numpy-1.18.1-cp36-cp36m-win_amd64.whl (12.8MB)

     |████████████████████████████████| 12.8MB 192kB/s

Collecting pandas>=0.24.2

  Downloading https://files.pythonhosted.org/packages/f0/ac/92c3d2f0b627efbd1a7b2156faa697f9c2bbd7b0fe83ba8a9d36f982156f/pandas-0.25.3-cp36-cp36m-win_amd64.whl (9.0MB)

     |████████████████████████████████| 9.0MB 1.3MB/s

Collecting matplotlib>=3.0.0

  Downloading https://files.pythonhosted.org/packages/44/fb/132de6a4b803d8ce909a89043b7d3f775f64e0a39398fc98c02e3e144b61/matplotlib-3.1.2-cp36-cp36m-win_amd64.whl (9.1MB)

     |████████████████████████████████| 9.1MB 49kB/s

Collecting scikit-learn>=0.20.3

  Downloading https://files.pythonhosted.org/packages/21/d9/7da9d5afdf901ab069226853c84a432c5db80fd616849ebcee29fd8a04e0/scikit_learn-0.22.1-cp36-cp36m-win_amd64.whl (6.3MB)

     |████████████████████████████████| 6.3MB 60kB/s

Requirement already satisfied: python-dateutil>=2.6.1 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2.7.3)

Requirement already satisfied: pytz>=2017.2 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2018.4)

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (2.2.0)

Requirement already satisfied: cycler>=0.10 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (0.10.0)

Requirement already satisfied: kiwisolver>=1.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (1.0.1)

Requirement already satisfied: six>=1.5 in c:\python\python36\lib\site-packages (from python-dateutil>=2.6.1->pandas>=0.24.2->mlxtend) (1.11.0)

Installing collected packages: numpy, scipy, joblib, pandas, matplotlib, scikit-learn, mlxtend

  Found existing installation: numpy 1.14.5

    Uninstalling numpy-1.14.5:

      Successfully uninstalled numpy-1.14.5

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\python\\python36\\lib\\site-packages\\~umpy\\.libs\\libopenblas.BNVRK7633HSX7YVO2TADGR4A5KEKXJAW.gfortran-win_amd64.dll'

Consider using the `--user` option or check the permissions.

 

 

C:\CodeLab>pip install mlxtend

Collecting mlxtend

  Using cached https://files.pythonhosted.org/packages/52/04/c362f34f666f0ddc7cf593805e64d64fa670ed96fd9302e68549dd48287d/mlxtend-0.17.0-py2.py3-none-any.whl

Collecting pandas>=0.24.2

  Using cached https://files.pythonhosted.org/packages/f0/ac/92c3d2f0b627efbd1a7b2156faa697f9c2bbd7b0fe83ba8a9d36f982156f/pandas-0.25.3-cp36-cp36m-win_amd64.whl

Requirement already satisfied: setuptools in c:\python\python36\lib\site-packages (from mlxtend) (39.0.1)

Collecting scipy>=1.2.1

  Using cached https://files.pythonhosted.org/packages/8d/2f/fcb6150813b89d628749784370132e431f687ebab5a1063eb298cc941f76/scipy-1.4.1-cp36-cp36m-win_amd64.whl

Collecting joblib>=0.13.2

  Using cached https://files.pythonhosted.org/packages/28/5c/cf6a2b65a321c4a209efcdf64c2689efae2cb62661f8f6f4bb28547cf1bf/joblib-0.14.1-py2.py3-none-any.whl

Collecting scikit-learn>=0.20.3

  Using cached https://files.pythonhosted.org/packages/21/d9/7da9d5afdf901ab069226853c84a432c5db80fd616849ebcee29fd8a04e0/scikit_learn-0.22.1-cp36-cp36m-win_amd64.whl

Collecting matplotlib>=3.0.0

  Using cached https://files.pythonhosted.org/packages/44/fb/132de6a4b803d8ce909a89043b7d3f775f64e0a39398fc98c02e3e144b61/matplotlib-3.1.2-cp36-cp36m-win_amd64.whl

Requirement already satisfied: numpy>=1.16.2 in c:\python\python36\lib\site-packages (from mlxtend) (1.18.1)

Requirement already satisfied: pytz>=2017.2 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2018.4)

Requirement already satisfied: python-dateutil>=2.6.1 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2.7.3)

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (2.2.0)

Requirement already satisfied: kiwisolver>=1.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (1.0.1)

Requirement already satisfied: cycler>=0.10 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (0.10.0)

Requirement already satisfied: six>=1.5 in c:\python\python36\lib\site-packages (from python-dateutil>=2.6.1->pandas>=0.24.2->mlxtend) (1.11.0)

Installing collected packages: pandas, scipy, joblib, scikit-learn, matplotlib, mlxtend

  Found existing installation: pandas 0.23.1

    Uninstalling pandas-0.23.1:

      Successfully uninstalled pandas-0.23.1

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\python\\python36\\lib\\site-packages\\~andas\\io\\msgpack\\_packer.cp36-win_amd64.pyd'

Consider using the `--user` option or check the permissions.

 

 

C:\CodeLab>pip show mlxtend

WARNING: Package(s) not found: mlxtend

 

C:\CodeLab>pip install mlxtend

Collecting mlxtend

  Using cached https://files.pythonhosted.org/packages/52/04/c362f34f666f0ddc7cf593805e64d64fa670ed96fd9302e68549dd48287d/mlxtend-0.17.0-py2.py3-none-any.whl

Collecting scipy>=1.2.1

  Using cached https://files.pythonhosted.org/packages/8d/2f/fcb6150813b89d628749784370132e431f687ebab5a1063eb298cc941f76/scipy-1.4.1-cp36-cp36m-win_amd64.whl

Requirement already satisfied: pandas>=0.24.2 in c:\python\python36\lib\site-packages (from mlxtend) (0.25.3)

Requirement already satisfied: numpy>=1.16.2 in c:\python\python36\lib\site-packages (from mlxtend) (1.18.1)

Requirement already satisfied: setuptools in c:\python\python36\lib\site-packages (from mlxtend) (39.0.1)

Collecting scikit-learn>=0.20.3

  Using cached https://files.pythonhosted.org/packages/21/d9/7da9d5afdf901ab069226853c84a432c5db80fd616849ebcee29fd8a04e0/scikit_learn-0.22.1-cp36-cp36m-win_amd64.whl

Collecting matplotlib>=3.0.0

  Using cached https://files.pythonhosted.org/packages/44/fb/132de6a4b803d8ce909a89043b7d3f775f64e0a39398fc98c02e3e144b61/matplotlib-3.1.2-cp36-cp36m-win_amd64.whl

Collecting joblib>=0.13.2

  Using cached https://files.pythonhosted.org/packages/28/5c/cf6a2b65a321c4a209efcdf64c2689efae2cb62661f8f6f4bb28547cf1bf/joblib-0.14.1-py2.py3-none-any.whl

Requirement already satisfied: python-dateutil>=2.6.1 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2.7.3)

Requirement already satisfied: pytz>=2017.2 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2018.4)

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (2.2.0)

Requirement already satisfied: kiwisolver>=1.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (1.0.1)

Requirement already satisfied: cycler>=0.10 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (0.10.0)

Requirement already satisfied: six>=1.5 in c:\python\python36\lib\site-packages (from python-dateutil>=2.6.1->pandas>=0.24.2->mlxtend) (1.11.0)

Installing collected packages: scipy, joblib, scikit-learn, matplotlib, mlxtend

  Found existing installation: scipy 1.1.0

    Uninstalling scipy-1.1.0:

      Successfully uninstalled scipy-1.1.0

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\python\\python36\\lib\\site-packages\\~cipy\\cluster\\_hierarchy.cp36-win_amd64.pyd'

Consider using the `--user` option or check the permissions.

 

 

C:\CodeLab>pip install mlxtend

Collecting mlxtend

  Using cached https://files.pythonhosted.org/packages/52/04/c362f34f666f0ddc7cf593805e64d64fa670ed96fd9302e68549dd48287d/mlxtend-0.17.0-py2.py3-none-any.whl

Collecting scikit-learn>=0.20.3

  Using cached https://files.pythonhosted.org/packages/21/d9/7da9d5afdf901ab069226853c84a432c5db80fd616849ebcee29fd8a04e0/scikit_learn-0.22.1-cp36-cp36m-win_amd64.whl

Requirement already satisfied: scipy>=1.2.1 in c:\python\python36\lib\site-packages (from mlxtend) (1.4.1)

Requirement already satisfied: numpy>=1.16.2 in c:\python\python36\lib\site-packages (from mlxtend) (1.18.1)

Requirement already satisfied: pandas>=0.24.2 in c:\python\python36\lib\site-packages (from mlxtend) (0.25.3)

Collecting joblib>=0.13.2

  Using cached https://files.pythonhosted.org/packages/28/5c/cf6a2b65a321c4a209efcdf64c2689efae2cb62661f8f6f4bb28547cf1bf/joblib-0.14.1-py2.py3-none-any.whl

Collecting matplotlib>=3.0.0

  Using cached https://files.pythonhosted.org/packages/44/fb/132de6a4b803d8ce909a89043b7d3f775f64e0a39398fc98c02e3e144b61/matplotlib-3.1.2-cp36-cp36m-win_amd64.whl

Requirement already satisfied: setuptools in c:\python\python36\lib\site-packages (from mlxtend) (39.0.1)

Requirement already satisfied: pytz>=2017.2 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2018.4)

Requirement already satisfied: python-dateutil>=2.6.1 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2.7.3)

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (2.2.0)

Requirement already satisfied: kiwisolver>=1.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (1.0.1)

Requirement already satisfied: cycler>=0.10 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (0.10.0)

Requirement already satisfied: six>=1.5 in c:\python\python36\lib\site-packages (from python-dateutil>=2.6.1->pandas>=0.24.2->mlxtend) (1.11.0)

Installing collected packages: joblib, scikit-learn, matplotlib, mlxtend

  Found existing installation: scikit-learn 0.19.1

    Uninstalling scikit-learn-0.19.1:

      Successfully uninstalled scikit-learn-0.19.1

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\python\\python36\\lib\\site-packages\\~klearn\\cluster\\_dbscan_inner.cp36-win_amd64.pyd'

Consider using the `--user` option or check the permissions.

 

 

C:\CodeLab>pip install mlxtend

Collecting mlxtend

  Using cached https://files.pythonhosted.org/packages/52/04/c362f34f666f0ddc7cf593805e64d64fa670ed96fd9302e68549dd48287d/mlxtend-0.17.0-py2.py3-none-any.whl

Requirement already satisfied: pandas>=0.24.2 in c:\python\python36\lib\site-packages (from mlxtend) (0.25.3)

Requirement already satisfied: joblib>=0.13.2 in c:\python\python36\lib\site-packages (from mlxtend) (0.14.1)

Requirement already satisfied: setuptools in c:\python\python36\lib\site-packages (from mlxtend) (39.0.1)

Requirement already satisfied: scikit-learn>=0.20.3 in c:\python\python36\lib\site-packages (from mlxtend) (0.22.1)

Requirement already satisfied: scipy>=1.2.1 in c:\python\python36\lib\site-packages (from mlxtend) (1.4.1)

Collecting matplotlib>=3.0.0

  Using cached https://files.pythonhosted.org/packages/44/fb/132de6a4b803d8ce909a89043b7d3f775f64e0a39398fc98c02e3e144b61/matplotlib-3.1.2-cp36-cp36m-win_amd64.whl

Requirement already satisfied: numpy>=1.16.2 in c:\python\python36\lib\site-packages (from mlxtend) (1.18.1)

Requirement already satisfied: pytz>=2017.2 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2018.4)

Requirement already satisfied: python-dateutil>=2.6.1 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2.7.3)

Requirement already satisfied: kiwisolver>=1.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (1.0.1)

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (2.2.0)

Requirement already satisfied: cycler>=0.10 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (0.10.0)

Requirement already satisfied: six>=1.5 in c:\python\python36\lib\site-packages (from python-dateutil>=2.6.1->pandas>=0.24.2->mlxtend) (1.11.0)

Installing collected packages: matplotlib, mlxtend

  Found existing installation: matplotlib 2.2.2

    Uninstalling matplotlib-2.2.2:

      Successfully uninstalled matplotlib-2.2.2

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\python\\python36\\lib\\site-packages\\~atplotlib\\backends\\_backend_agg.cp36-win_amd64.pyd'

Consider using the `--user` option or check the permissions.

 

 

C:\CodeLab>pip install mlxtend

Collecting mlxtend

  Using cached https://files.pythonhosted.org/packages/52/04/c362f34f666f0ddc7cf593805e64d64fa670ed96fd9302e68549dd48287d/mlxtend-0.17.0-py2.py3-none-any.whl

Requirement already satisfied: matplotlib>=3.0.0 in c:\python\python36\lib\site-packages (from mlxtend) (3.1.2)

Requirement already satisfied: numpy>=1.16.2 in c:\python\python36\lib\site-packages (from mlxtend) (1.18.1)

Requirement already satisfied: pandas>=0.24.2 in c:\python\python36\lib\site-packages (from mlxtend) (0.25.3)

Requirement already satisfied: setuptools in c:\python\python36\lib\site-packages (from mlxtend) (39.0.1)

Requirement already satisfied: joblib>=0.13.2 in c:\python\python36\lib\site-packages (from mlxtend) (0.14.1)

Requirement already satisfied: scikit-learn>=0.20.3 in c:\python\python36\lib\site-packages (from mlxtend) (0.22.1)

Requirement already satisfied: scipy>=1.2.1 in c:\python\python36\lib\site-packages (from mlxtend) (1.4.1)

Requirement already satisfied: python-dateutil>=2.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (2.7.3)

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (2.2.0)

Requirement already satisfied: kiwisolver>=1.0.1 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (1.0.1)

Requirement already satisfied: cycler>=0.10 in c:\python\python36\lib\site-packages (from matplotlib>=3.0.0->mlxtend) (0.10.0)

Requirement already satisfied: pytz>=2017.2 in c:\python\python36\lib\site-packages (from pandas>=0.24.2->mlxtend) (2018.4)

Requirement already satisfied: six>=1.5 in c:\python\python36\lib\site-packages (from python-dateutil>=2.1->matplotlib>=3.0.0->mlxtend) (1.11.0)

Installing collected packages: mlxtend

Successfully installed mlxtend-0.17.0

 

C:\CodeLab>

 

 

 

 

 


Posted by codedragon codedragon

댓글을 달아 주세요

2020. 1. 25. 00:30

ndarray vs list Development/Python



 

ndarray vs list

ndarray

list

[10 20 30 40]

[50, 60, 70, 80]

리스트 내 요소를 구분하는 쉼표(,) 없습니다.

리스트 내 요소를 구분하는 쉼표(,) 있습니다.

가지 타입의 데이터만을 저장할 수 있습니다.

정수, 문자열, 리스트 등 다양한 데이터 타입을 담을 수 있습니다.

 

 


Posted by codedragon codedragon

댓글을 달아 주세요


 

 PyPI - the PYthon Package Index

·         Python Repository 패키지 정보입니다.

·         pip으로 설치할 있는 패키지들의 목록 추가 정보를 확인할 있습니다.

·         파이썬 모듈 중앙 저장소입니다.

 

 

https://pypi.python.org/pypi


 

Posted by codedragon codedragon

댓글을 달아 주세요



 

 

주소록 만들기

table형태의 주소록 데이터를 파이썬 데이터로 표현하고 데이터 구조 이해하기

 

 

id

name

email

tel

1

hong gildong

gildong@google.com

010-1234-5678

2

kim yuna

yuna@facebook.com

010-5678-1234

3

Bae suji

suji@naver.com

010-4567-2345

4

Park jisung

jisung@twitter.com

010-9853-4567

5

kim coding

coding@kakao.com

010-3456-2345

 

 

딕셔너리를 사용하여 데이터를 표현합니다.(Case1)

·       id 키로하는 딕셔너리로 만들기

·       로우(row; ) 딕셔너리로 표현합니다.

·       모든 딕셔너리를 포함한 하나의 리스트를 만듭니다.

 

리스트와 딕셔너리를 사용하여 데이터를 표현합니다. (Case2)

·       딕셔너리를 가진 리스트로 만들기

·       로우(row; ) 딕셔너리로 표현합니다.

·       모든 딕셔너리를 포함한 하나의 리스트를 만듭니다.

 

 

데이터 출력

Case1, Case2으로 데이터를 만들고

id 1 데이터만 예상 출력결과와 같이 출력하시오.

 

 

 

 

예상 출력 결과

name : hong gildong

email : gildong@google.com

tel: : 010-1234-5678

name : hong gildong

email : gildong@google.com

tel: : 010-1234-5678

 

 



'Development > Python' 카테고리의 다른 글

ndarray vs list  (0) 2020.01.25
PyPI - the Python Package Index  (0) 2020.01.24
LAB - 주소록 만들기  (0) 2020.01.24
meshgrid()  (0) 2020.01.23
파이썬 리스트를 사용 - 배열 생성 방법  (0) 2020.01.23
NumPy 유래  (0) 2020.01.23
Posted by codedragon codedragon

댓글을 달아 주세요

2020. 1. 23. 17:31

meshgrid() Development/Python



 

 

meshgrid()

·       그리드 포인트(2차원 좌표값)를 만들어주는 함수입니다.

·       meshgrid()함수는 사각형 영역을 구성하는 가로축의 점들과 세로축의 점을 나타내는 두 벡터를 인수로 받아서 이 사각형 영역을 이루는 조합을 출력합니다.

·       결과는 그리드 포인트의 x 값만을 표시하는 행렬과 y 값만을 표시하는 행렬 두 개로 분리하여 출력합니다.

 

 

 

import numpy as np

 

np.meshgrid(np.linspace(hour_class.study_hours.min(),hour_class.study_hours.max(),100),

                  

 

 

 


'Development > Python' 카테고리의 다른 글

PyPI - the Python Package Index  (0) 2020.01.24
LAB - 주소록 만들기  (0) 2020.01.24
meshgrid()  (0) 2020.01.23
파이썬 리스트를 사용 - 배열 생성 방법  (0) 2020.01.23
NumPy 유래  (0) 2020.01.23
NumPy 설치  (0) 2020.01.23
Posted by codedragon codedragon

댓글을 달아 주세요