Python - json 파일 읽기
# json 파일 읽기 # csv : , 기준으로 데이터 분리 저장 # excel: 이진 파일, 메모장에서 볼 수 없음. 유틸리티 필요함 # => 컬럼 기준으로 데이터의 의미부여 # 단어 자체에 의미 부여 : 홍길동, 80, A, 170 # xml 문서로 저장 # 홍길동80A170 # json 문서로 저장 #텍스트 문서임 ''' { "이름":'홍길동', "몸무게":80, "학점":"A", "키":170 } ''' ### json 형태의 파일 읽기 df3 = pd.read_json("read_json_sample.json") df3 ### json 데이터 연습 import json price = { "date" : "2021-02-17", "price" :{ "Apple":800, "Orange":1000..
Python - 판다스 기초, 데이터프레임(대표값, 데이터프레임복사, 행/열 삭제)
# 판다스의 series 데이터셋 # dictionary를 Series 데이터로 저장하기 import pandas as pd dict_data = {'a':1,'b':2,'c':3} sr = pd.Series(dict_data) print(type(sr)) print(sr) print(sr.index) print(sr.values) # 리스트를 시리즈 데이터로 저장 list_data = ['2019-01-02', 3.14, 'ABC', 100, True] sr = pd.Series(list_data) print(sr) print(sr.index) print(sr.values) # tuple을 시리즈 데이터로 저장 tup_data = ('길동',"1990-01-01","남자",True) sr = pd.Se..
Python - Database 연습문제
''' 1. select 구문을 입력하고 다음과 같은 결과가 출력되도록 프로그램을 작성하시오 [결과] sql 입력하세요========= select * from dept 조회 레코드수: 4 ,조회 컬럼수:3 (10, 'ACCOUNTING', 'NEW YORK') (20, 'RESEARCH', 'DALLAS') (30, 'SALES', 'CHICAGO') (40, 'OPERATIONS', 'BOSTON') sql 입력하세요========= select studno,name from student where grade = 1 조회 레코드수: 5 ,조회 컬럼수:2 (9711, '이윤나') (9712, '안은수') (9713, '인영민') (9714, '김주현') (9715, '허우') sql 입력하세요==..
Python - 모듈
1) mod1.py 파일 생성 2) mod2.py 파일 생성 # 모듈 import mod1 import mod2 print("mod1 모듈",mod1.add(4,3)) print("mod1 모듈",mod1.sub(4,2)) print("mod1 모듈",mod1.add(4,3)) print("mod1 모듈",mod1.sub(4,2)) from mod1 import add #mod1 모듈에서 add함수만 import함. sub함수는 사용 못함 print(add(3,4)) #print(sub(3,4)) from mod1 import add,sub print(add(3,4)) print(sub(3,4)) print("mod1:",dir(mod1)) #mod1에서 사용 가능한 목록 보기 print("mod2:",..