Programming

Programming

remote: Internal Server Error

git push를 하는데 이런 오류가 나왔다 pull도 다 되어있는데 계속 push가 안되었는데 이유는 한 번에 push하는 데이터가 너무 많을 때 생긴다고 한다! GitHub seems quite limited in terms of the number of refs that can be pushed at once. When a repository contains 100+ refs, a single push would return a "remote: Internal Server Error". Push with 100+ refs fails with "remote: Internal Server Error" · Issue #1253 · isaacs/github I've already opened a ticke..

Programming/Pandas

[pandas] DataFrame Indexing & Slicing

idols = { '그룹' : ['마마무', '에이핑크', '투피엠', '비투비'], '멤버수' : [4, 6, 6, 6], '데뷔년도' : ['2014', '2011', '2008', '2012'], '소속사' : ['rbw', 'ist', 'jyp', 'cube'] } df = pd.DataFrame(idols, columns=['소속사', '데뷔년도', '그룹', '멤버수'], index=['1', '2', '3', '4']) Column Indexing 하나의 column만 추출하기 group = df['그룹'] group Series 타입으로 반환된다. 1 마마무 2 에이핑크 3 투피엠 4 비투비 Name: 그룹, dtype: object 이렇게 생성된 Series는 원복에서 복사된 것이 아니라..

Programming/Pandas

[pandas] 여러가지 resource를 이용하여 DataFrame 생성하기 (csv, sql, api, json)

pandas를 이용해서 데이터의 양은 방대하므로 직접 만들지 않고 외부에서 가져오는 경우가 많다 csv read_csv('file 경로') 첫 줄을 columns 명으로 데이터를 가져온다. df = pd.read_csv('./data/student.csv') Mysql read_sql('sql', 'database') 외부모듈 pymysql이 필요하다 설치 conda install pymysql # 또는 pip install pymysql # 1. Database 연결 con = pymysql.connect(host = 'localhost', user='root', password='password', db='database_name', charset='utf8') # 2. sql 작성 sql = 'SE..

Programming/Pandas

[pandas] 데이터 조작 및 분석을 위한 python module - pandas

pandas에는 두 가지 데이터 타입이 있다 Series : 1차원 자료구조. DataFrame : 2차원 자료구조. pandas는 내부적으로 numpy array를 이용하고 있으므로 ndarray와 같이 같은 타입의 데이터만 저장이 가능하다. pandas 데이터 타입은 숫자 인덱스 외에 별도로 문자 인덱스(지정인덱스)를 사용할 수 있다는 특징도 있다. 설치 conda install pandas 1. Series # ndarray ndarr = np.array([1,2,3,4,5], dtype=np.float64) print("ndarr : \n", ndarr) # series s = pd.Series([1,2,3,4,5], dtype=np.float64) print("\n1. Series :\n", s..

Programming/Numpy

[numpy] ndarray의 indexing과 slicing

indexing의 방법은 기본적으로 python list와 동일하다. 2차원 이상의 배열에서는 훨씬 편리하게 슬라이싱을 할 수 있다. arr = np.arange(0, 25).reshape(5, 5) print("arr:\n",arr) print("1 :\n", arr[1:4, 1:4]) print("2 :\n", arr[1:3]) print("3 :\n", arr[:, [0]]) print("4 :\n", arr[1]) print("4-1 :\n", arr[1, :]) arr: [[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14] [15 16 17 18 19] [20 21 22 23 24]] 1 : [[ 6 7 8] [11 12 13] [16 17 18]] 2 : [[ 5 6 ..

Programming/Numpy

[numpy] ndarray의 shape과 관련된 함수들

reshape() revel() resize() reshape() ndarray의 차원과 크키 변경 arr = np.arange(10) print(arr) arr2 = arr.reshape(2, 5) print(arr2) arr3 = arr.reshape(5, -1) print(arr3) # arr [0 1 2 3 4 5 6 7 8 9] # arr2 [[0 1 2 3 4] [5 6 7 8 9]] # arr3 [[0 1] [2 3] [4 5] [6 7] [8 9]] -1을 인자로 사용하면 원래 배열과 호환되는 새로운 shape으로 변환해 주며, 지정된 사이즈로 변경이 불가능하면 error가 나타난다. (= 요소의 수가 맞지 않으면 view가 생성되지 않는다.) arr4 = arr.reshape(4, -1)..

Programming/Numpy

[numpy] ndarray를 생성하는 여러가지 방법 2 - random

ndarray를 생성할 때 random을 이용하면 난수로 값을 채우며 생성할 수 있다. np.random.normal np.random.rand np.random.randn np.random.radint np.random.random np.random.normal(mean, std, shape) 정규분포에서 실수 표본을 추출하여 생성 mean = 0 std = 1 # 표준정규분포 arr = np.random.normal(mean, std, (1000000,)) print(arr) # 정규분포에 진짜로 따르는지 확인 plt.hist(arr, bins=100) plt.show() [ 0.80853868 -0.27112114 1.74376676 ... 0.65221723 0.74973141 0.03062562..

Programming/Numpy

[numpy] ndarray를 생성하는 여러가지 방법 1

이전 포스팅에서 다룬 생성 방법은 리스트에 데이터가 있을 때 리스트를 ndarray로 생성하는 방법이다. 데이터가 없을 때, ndarray를 초기화하고 싶을 때 등의 경우에는 어떻게 해야할까? 리스트를 초기화해서 ndarray로 변환할 수도 있겠지만 numpy에서 쉽게 초기화 할 수 있는 기능을 제공한다. arange(x) : 0부터 x-1까지의 값을 순차적으로 ndarray값으로 변환 a = np.arange(10) a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) zeros((x, y), dtype) : (x, y) shape의 ndarray의 값을 모두 0으로 초기화 하여 생성. default dtype은 float a = np.zeros((2,2,3), 'int32') #면,..

Heaea
'Programming' 카테고리의 글 목록 (6 Page)