목록프로그래밍/Python (16)
비전공개미 개발노트
# sns.py import seaborn as sns import matplotlib.pyplot as plt import numpy as np import pandas as pd iris = sns.load_dataset("iris") titanic = sns.load_dataset("titanic") tips = sns.load_dataset("tips") flights = sns.load_dataset("flights") x = iris.petal_length.values # # sns.rugplot(x) # sns.rugplot(data=iris, x="petal_length") # sns.kdeplot(x) # sns.distplot(x, kde=True, rug=True) # sns.hist..
# pdplot.py import numpy as np import pandas as pd import matplotlib.pyplot as plt np.random.seed(0) #seed값을 기준으로 랜덤값이 만들어진다(숫자에 큰 의미는 없음) df = pd.DataFrame(np.random.randn(100, 3), index=pd.date_range("12/1/2022", periods=100), #date_range("월/일/년도") columns=["A", "B", "C"]).cumsum() # print(df.tail()) # df.plot() # plt.xlabel("Time") # plt.ylabel("Value") # plt.title("Income") import seaborn as..
# Pandas import pandas as pd # Series s = pd.Series([1, 0, -4, 6, -7, -3, 5, 3, -9, 2]) print(s) print(type(s)) print(s.index) print(s.values) print(type(s.values)) s.index = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] print(s) # 값과 index를 같이 출력 / ([값], [인덱스]) s = pd.Series([1, 0, -4, 6, -7, -3, 5, 3, -9, 2], ["a", "f", "c", "d", "e", "b", "g", "h", "i", "j"]) print(s) print(s.index) # 값 ..
# -*- coding: utf-8 -*- # Numpy import numpy as np for str in dir(np): print(str) print(help(np)) print(help(np.dtype)) b = [i for i in range(15)] print(b) a = np.arange(15).reshape(3,5) print(a) print(a.shape) print(a.ndim) print(a.dtype) print(a.itemsize) print(a.size) print(type(a)) t = (10, 20, 30, 40, 50) print(type(t)) tt = np.array(t) print(type(tt)) s = {10, 20, 30, 40, 50} print(type(s)..
In [54]: class Student: # dto, vo def __init__(self, name, number, lang, eng, math): self.name = name self.number = number self.lang = lang self.eng = eng self.math = math # 확인용 def dataPrint(self): print(self.name, self.number, self.lang, self.eng, self.math) In [55]: class StudentDao(Student): # Data Access Object == CRUD def __init__(self): self.student_list = [] # 테스트 넣어놓기 self.student_list...
In [ ]: ''' Numpy : Numerical Python 벡터, 행렬(매트릭스) 계산하는 용도의 module ''' In [1]: import numpy as np In [11]: a = np.array([1, 2, 3]) a a * 3 # 기존 배열의 3개 반복이 아닌 곱하기 3의 값이 들어간다 a[0] Out[11]: 1 In [12]: b = np.array([2, 2, 1]) a / a Out[12]: array([1., 1., 1.]) In [14]: np.dot(a, b) # 1*2 + 2*2 + 3*1 = 9 / 각 배열 순서를 곱한값을 전부 더한값 Out[14]: 9 In [18]: c = range(10) print(c) d = np.arange(10) print(d) d = n..
In [3]: ''' OOP (Object Oriented Programing) 변수(저장), 함수(처리) 일반변수, tuple(변경불가능한 리스트), list, dictionary(자바의 map) list 접근 : index number 0 ~ length-1 -> 번호(숫자), dictionary 접근 : key(string) : value, OOP (Object Oriented Programing) class 변수(멤버) 초기화 함수 __init__ 함수(멤버) -> method ''' class Car: def __init__(self): print('Car __init__') car = Car() car.__init__() # 자바와는 다르게 따로 호출이 가능하다 Car __init__ Car ..
In [11]: honk = '빵빵' color = 'black' engine = '보통' honk = '빵빵' color = 'black' engine = '보통' mycar_honk = [] mycar_color = [] mycar_engine = [] mycar_honk.append('띠띠') mycar_color.append('노랑') mycar_engine.append('터보') mycar_honk.append('빵빵') mycar_color.append('블루') mycar_engine.append('250cc') # ---------------------------------------------- class Car: honk = '빵빵' color = '검정' engine = '보통' ca..