전체 글
-
데이터 로딩과 저장, 파일 형식Python 2023. 11. 20. 17:15
데이터 로딩(data loading)은 데이터를 읽고 접근 가능하도록 하는 작업, 데이터 분석에서의 도구를 사용하는 첫 번째 단계 유사한 용어인 파싱(parsing)(구문 분석)은 텍스트 데이터를 불러와 표나 다른 데이터 형식으로 해석하는 과정 텍스트 파일에서 데이터를 읽고 쓰는 법 In [1]: !cat ex1.csv 'cat'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다. In [2]: !type ex1.csv a,b,c,d,message 1,2,3,4,hello 5,6,7,8,world 9,10,11,12,foo 유닉스의 cat 명령어를 통해 파일 내용 확인, 윈도우 사용자는 type 명령어로 확인 가능 자동으로 제일 위에 있는 열이 열 이름으로 들어감 In ..
-
-
판다스Python 2023. 11. 14. 17:15
고수준의 자료구조와 파이썬을 통한 빠르고 쉬운 데이터 분석 도구 제공, 넘파이의 배열 기반의 계산 스타일을 많이 차용함 판다스, 넘파이의 가장 큰 차이점은 판다스는 표 형식의 데이터나 다양한 형태의 데이터를 다루는 데 초점을 맞춰 설계, 넘파이는 단일 산술 배열 데이터를 다루는 데 특화되어 있음 넘파이와 판다스의 import 컨벤션 In [1]: import numpy as np In [2]: import pandas as pd Series와 DataFrame은 로컬 네임스페이스로 임포트하는 것이 편하므로 다음과 같이 사용 In [3]: from pandas import Series, DataFrame 판다스 자료구조 소개 두 가지 자료구조 Series와 DataFrame Series 일련의 객체를 담을..
-
SQL 고급데이터베이스/SQL 2023. 11. 9. 15:14
숫자 데이터 형식(많이 쓰게 될) 데이터 형식 바이트 수 설명 INT 4 정수 FLOAT 4 소수점 아래 7자리까지 표현 DOUBLE 8 소수점 아래 15자리까지 표현 변수의 사용 SQL도 다른 일반적인 프로그래밍 언어처럼 변수를 선언하고 사용할 수 있음 SET @변수이름 = 변수의 값 ; -- 변수의 선언 및 값 대입 SELECT @변수이름 ; -- 변수의 값 출력 변수는 HeidiSQL을 재시작할 때까지는 계속 유지되지만, HeidiSQL을 닫았다가 재시작하면 소멸됨 데이터 형식과 형 변환 CAST(), CONVERT() 함수를 사용, 두 함수는 거의 비슷한 기능을 함 CAST( expression AS 데이터형식 [ (길이) ] ) CONVERT( expression , 데이터형식 [ (길이) ] ..
-
넘파이 기본: 배열과 벡터 연산Python 2023. 11. 7. 17:02
Numerical Python의 준말로 파이썬에서 산술 계산을 위한 가장 중요한 필수 패키지 중 하나 과학 계산을 위한 대부분의 패키지는 넘파이의 배열 객체를 데이터 교환을 위한 공통 언어처럼 사용 > 넘파이와 관련된 대부분의 지식은 판다스에도 그대로 적용 가능 넘파이 제공 기능 · 빠른 배열 계산과 유연한 브로드캐스팅 기능을 제공하는 효율적인 다차원 배열인 ndarray · 반복문을 작성할 필요 없이 전체 데이터 배열을 빠르게 계산하는 표준 수학 함수 · 배열 데이터를 디스크에 쓰거나 읽을 수 있는 도구와 메모리에 적재된 파일을 다루는 도구 · 선형대수, 난수 생성기, 루리에 변환 가능 · C, C++, 포트란으로 작성된 코드를 넘파이와 연결하는 C API 데이터 분석 애플리케이션에서 중요하게 여겨지는..
-
파이썬 기초와 Ipython, jupyter notebookPython 2023. 10. 31. 17:42
C:\Users\Desktop\project\basic>python hello.py hello.py __main__ C:\Users\Desktop\project\basic>ipython In [1]: %run hello.py hello.py __main__ In [2]: an_apple = 27 In [3]: an_example = 42 an 입력하고 tap 키 누르면 자동 완성 기능 제공 자기관찰(인트로스펙션 introspection) In [3]: b = [1, 2, 3] In [4]: b? Type: list String form: [1, 2, 3] Length: 3 Docstring: Built-in mutable sequence. If no argument is given, the constru..
-
웹의 데이터로 그래프 그리기Python 2023. 10. 31. 12:45
주피터 노트북 사용 기본 code로 되어 있는 것 markdown으로 바꿔서 작성하면 위와 같이 사용 가능 웹 페이지의 HTML 가져와 파일로 저장하기 웹 브라우저에서 F12 누르고 개발자 도구 표시 주피터 노트북 만들기 import requests # 웹 페이지의 HTML을 가져오는 모듈 from bs4 import BeautifulSoup # HTML을 파싱하는 모듈 # 웹 페이지를 가져온 뒤 BeautifulSoup 객체로 만듦 response = requests.get('https://pythondojang.bitbucket.io/weather/observation/currentweather.html') soup = BeautifulSoup(response.content, 'html.parser'..
-
모듈과 패키지 만들기Python 2023. 10. 30. 16:27
모듈 만들기 # square2.py base = 2 # 변수 def square(n): # 함수 return base ** n 모듈 사용 # main.py # import 모듈 # 모듈.변수 # 모듈.함수() import square2 print(square2.base) print(square2.square(10)) # 실행 결과 2 1024 from import로 변수, 함수 가져오기 # from 모듈 import 변수, 함수 from square2 import base, square print(base) print(square(5)) # 실행 결과 2 32 모듈에 클래스 작성 # person.py class Person: # 클래스 def __init__(self, name, age, addr): s..