Programming 6

[Pandas] 데이터프레임(dataframe) 정렬 방법 (sort.index(), sort.values())

Pandas로 생성한 데이터프레임 정렬하는 방법 모음 예제는 가장 많이 쓰이는 kaggle의 titanic 사용 sort_values() column의 값(value)을 기준으로 정렬 자주쓰는 parameter: sort_values(by, ascending=True, inplace=False) by: 기준이 되는 column ('by='을 생략해서 작성해도 가능) ascending: 오름차순(True) / 내림차순(False) inplace: 원본변경(True) / 원본 미변경(False) import pandas as pd # train.csv의 data를 'Age' column의 오름차순으로 정렬 data = pd.read_csv('train.csv') data.sort_values('Age') s..

Programming/Pandas 2022.04.03

VScode(Visual Studio Code) python관련 확장(extension) 플러그인 설치 및 설치 확인

VScode에서 python을 사용하기 위한 기본적인 플러그인 설치 방법 이전 VScode 소개에서 언급했듯이 VScode의 장점중 하나는 플러그인 설치를 통해서 IDE (Integrated Development Envirionment) 같은 효과를 낼 수 있다는 점이다. 이번 글에서는 VScode 설치가 완료된 후 python을 사용하기 위한 정말 기본적인 확장 플러그인을 소개하고 설치 방법을 공유해본다. (해당 내용은 Window 10 기준으로 작성되었습니다.) Python Extension 설치 설치방법은 여기 우선 VScode 설치 후 실행하면 다음과 같이 나온다. (오른쪽하단에 위치한 언어팩을 설치하고 싶은 생각이 본능적으로 생기지만, 설치하고 나서 한글로 보면 더 알아보기 힘들다는 것을 깨닫고..

VScode(Visual Studio Code) 설치 방법

VScode 설치방법 VScode에 대한 설명은 여기 설치 방법은 일반적인 프로그램 설치방법과 크게 다르지 않다. VScode 홈(code.visualstudio.com)으로 이동하여 본인의 OS에 맞는 설치파일 다운로드 Visual Studio Code - Code Editing. Redefined Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. code.visual..

[Python] 기본 유용한 사용법 (Main 선언, cell 생성)

Python 관련하여 따로 글을 작성하긴 애매한 것들 모음 python 파일 (*.py)에서만 해당되는 유용한 팁 Main 선언 별거없다. if __name__ == "__main__" 작성후 들여쓰기로 main 내용 작성 # main.py def function(): # 함수 작성 if __name__ == "__main__": # 선언된 함수나 main 내용 작성 function() Reference : https://madplay.github.io/post/python-main-function cell 생성 긴 코드를 구분지어서 작성 & 실행시키기 위한 cell (MATLAB에서는 section이라고 한다.) cell 선언하려는 영역 시작점에 #%% 작성 (뒤에 작성하는 text는 cell의 tit..

Programming/Python 2022.02.23

VScode(Visual Studio Code)란 무엇인가? (특징, 순위)

Python을 하는데 jupyter notebook과 spyder만 사용해 본 필자는 최근 핫하다는 VScode를 사용해 보기로 했다. VScode (Visual Studio Code) 특징 Microsoft에서 개발한 test editor (즉, 엄밀히 따지면 IDE가 아님. 나에겐 그렇게 의미가 있겠냐만은..) 여기서 IDE (Integrated Development Envirionment)는 개발을 위한 통합 환경(코딩-디버그-컴파일-배포 등)을 의미하며 Visual Studio Eclipse가 대표적인 IDE라고 할 수 있다. Text editor: 코딩을 위한 편집기 1세대(메모장, 워드패드), 2세대(울트라 에디터, 에디터 플러스)에 이어 3세대(Subline Text, Atom, Visual..

[Pandas] 데이터프레임(dataframe) 시리즈(series)의 요소에 접근(access)하는 방법 (특정 값에 접근하는 방법) <함수 없이, iloc, iat, loc, at>

Recommendation 함수 사용없이 접근하는 방법 df[column][index], = df.column[index] df[column].values[index] loc, at : Dataframe 값(value)에 접근 at: Dataframe의 하나의 행(row)이나 칼럼(column) 값에 접근 loc: Dataframe의 복수의 행(row)이나 칼럼(column) 값들에 접근 iloc, iat (prefix i- 가 붙는 경우): Dataframe 순서(index)에 접근 iat: Dataframe의 하나의 행(row)이나 칼럼(column) 순서에 접근 iloc: Dataframe의 하나의 행(row)이나 칼럼(column) 순서들에 접근 Comment 당연한 얘기지만, 이렇게 구분해서 만..

Programming/Pandas 2022.02.20