본문 바로가기

Upstage AI Lab 2기

Upstage AI Lab 2기 [Day002] (2-1) 한 번에 끝내는 데이터 사이언스 (1)

Upstage AI Lab 2기

2023년 12월 12일 (화) Day_002

더보기

온라인 강의 진행 일정 #01

1. 한 번에 끝내는 데이터 사이언스 (12/12화, 12/14목, 12/28목, 1/23화, 1/25목, 1/30화)

2. 파이썬으로 할 수 있는 모든 것 with 47개 프로젝트  (12/12화, 12/14목, 12/28목)

 

강의명 :  한 번에 끝내는 데이터 사이언스

더보기

12월 12일 (화) 수강범위

Part.3 파이썬 기초와 데이터분석 - Chapter.01 파이썬 프로그래밍 (3:57:29)

 

CH01_01. 프로그래밍이란 0:23:24
CH01_02. Python 소개 0:22:18
CH01_03. Data Type (이론) 0:12:24
CH01_04. Data Type (실습) 1:38:50
CH01_05. IF (이론) 0:11:35
CH01_06. IF (실습) 0:17:13
CH01_07. for, while (이론) 0:11:53
CH01_08. for, while (실습) 0:39:52

 

 

01. 프로그래밍이란

"컴퓨터에게 일을 시킨다." → 소통수단 필요

소통수단 = 프로그래밍 언어

 

프로그래밍 언어는 '언어'이기 때문에 문법(syntax)과 의미론(semantic)이 중요하다.

 

Computer Architecture (= Von Neumann Architecture)

1. CPU : 연산 (Control Unit, ALU, registers)

2. Main Memory (주로 DRAM) : 프로그래밍 할 때 사용하는 모든 데이터와 코드가 올라와 있는 공간

3. I/O Devices : Storage(HDD, SSD, CD, USB etc.) / monitor, mouse, keyboard etc.

    Load&Save 모두 I/O에 해당. (CPU ↔ Storage)

note.

메모리와 스토리지 구분을 위해 warning도 메모리부족 / 스토리지 부족으로 구분

 

# instruction cycle

Memory ↔ CPU(decode&execute)

이 프로세스를 fetch라고 부름

 

 

02. Python 소개

Programming Language (   Natural Language) - 프로그래밍 언어는 만들어진 목적이 존재함.

python

: 데이터 분석, 프로토타입 개발 등에 많이 활용

Interpreter-based & OOP & Dynamic Type Binding

(참고 : compiler 기반 언어 vs. interpreter 기반 언어)

 

특징

1. variable 선언 시 자동으로 data type 결정

2. indentation으로 code block 구분

3. str type이 별도 존재. (string 사용 편리)

4. line by line 실행

 

※ PyPI(Python Package Index)라는 코드 저장소를 운영하여 확장성이 좋음.

pip install "package name"

 

 

03. Data Type (이론)

int / float / str / list / tuple / set / dict

 

04. Data Type (실습)

1. numeric data types (int, float, etc.)

note. 이진수로밖에 표시를 못 해 실수 표현의 한계 → 보완 위해 numpy 사용

 

2. string data types

 - escape code

 - string formatting (print formatting / str.format / f-string)

 - functions : string.upper(), string.lower(), string.strip(), string.join(string2), string.split(), string.replace(a,b)

 

3. sequential data types (list / tuple / set / dict)

※ indexing

※ slicing - list, numpy array, pandas series, dataframe 에서도 많이 사용

 

 3-1. list [ ]

  빈 리스트 생성 ① L1 = [] ② L2 = list() list 클래스의 생성자 호출

  - functions : 

  append(), sort(), sort(reverse = True), reverse(), pop(), insert(), remove()

note. list.reverse()와 같은 결과 list[::-1] → numpy에서 설명

 

 3-2. tuple ( )

  빈 튜플 생성 t1 = ()

list vs. tuple
(mutable)   (immutable)

 

 

 3-3. set (원소중복 X, index X)

  빈 집합 생성 s = set() / 집합 선언 s = {e1, e2, e3, ...}

  - functions : 

  교집합 : A & B 또는 A.intersection(B)

  합집합 : A | B 또는 A.union(B)

  차집합 : A - B

  add(), update(), remove()

 

 3-4. dict { }

  key - value mapping : key값을 통해 value에 access (∴ key는 절대 중복 X & immutable)

  - functions : 

  keys(), values(), items(), get()

 

 

 

 

NOTE (to update)

  empty 생성              
list list = [] .append()            
set s = set() .add()