본문 바로가기
Python Pandas2 #index.name #set_index 전체코드 import pandas as pd data = { 'area' : ['서울','경기도','제주도'], 'gas' : [1150,1200,980], 'diesel' :[1860,1845,1998], 'gasoline' : [1750,1700,1810] } pr=pd.DataFrame(data) #index.name : 표이름 pr.index.name='지역별 유가' print(pr) pr2=pd.DataFrame(data) #index 번호를 데이터 키값에 맞춰 변동한 상태 print(pr2.set_index("area")) #표 이름 정하기: index.name #인덱스 기준 변경 2022. 9. 26.
Python Padas1 정리 #Series #DataFrame pandas pip install 이후 #Series 로 배열을 시각화 한다. import pandas as pd #Series => Time, Num, Data (간격에 맞춰서 배치된 데이터) data = pd.Series([10,20,30,40]) #Series로 배열값 로드 (인덱스 자동 설정) print(data) #Series + index를 이용해 인덱스 이름을 정할 수 있다. #index 기본 숫자 (0 부터 시작) 데이터 인덱스 이용해서 이름 지정가능함 data2 = pd.Series([17,19,20,17,16,15,16],index=['월','화','수','목','금','토','일']) print(data2) print(data2['토']) #지정된 index 별명 출력할 수 있음 #D.. 2022. 9. 26.
사이트 크롤링이 어려운 case ajax-script로 HTML 작성했을 때 이미지를 jpg, png, bmp, gif 속성이 없는 주소로 되어있는 이미지 예)http://abc.co.kr/imgs/a213123dsfas python requests로 접속시도하면 해당 IP차단 검색봇(구글,네이버,네이트 등)을 이용해서 허용경로만 웹페이지 볼 수 있도록 할 때 (어뷰징) [차단 우선순위] Front-end (Ajax, react, vue, angular 이용) Back-end (API서버 증설 (Rest,Restful API) 2022. 9. 26.
Python PIP 설치 LIST [설치방법] 명령 프롬프트 실행 명령 CMD cd\ cd C:\Program Files\Python310 (파이썬 설치 경로) cd Scripts dir/w (안되면 안해도됨) pip install pip네임명 attrs beautifulsoup4 dbConnect lxml mysqlclient webdriver-manager urllib3 selenium sniffio soupsieve pyinstaller pefile bs4 pysqlite3 pysqlite tkinter requests matplotlib 2022-09-26 추가 xlwt 2022-09-26 추가(엑셀) openpyxl 2022-09-26 추가(엑셀) 2022. 9. 26.
Python databases 연결 =sql2 update, delete, create 공통 import from sqlite3 import * #pip install pysqlite3 from dbconnect import * from random import * #update for a in range(20,23): #sql index 고유값 범위선정 cur= connect.cursor() #해당 index값 모두 변경 되게 반복 시킴 sql = "update test3 set mpw='pass1234' where midx='"+str(a)+"'" #%s 사용시 sql 문법 전체를 %s로 적용해야만 정상적으로 반영 cur.execute(sql) connect.commit() 20~22번 insert 이후 update #delete cur=connect.cursor() for b in r.. 2022. 9. 22.