| import cx_Oracle import pandas as pd dsn = cx_Oracle.makedsn('DESKTOP-7KQ0VF0', 1521, 'xe') # 3가지 정보를 기술 db = cx_Oracle.connect('c##scott', 'tiger', dsn) # 오라클에 접속할 유저 이름과 패스워드 기술 cursor = db.cursor() # SQL 수행결과 데이터를 담을 메모리 이름을 cursor 로 선언함 cursor.execute("""select * from emp15""") # 작성한 쿼리문의 결과가 cursor 메모리에 담김 row = cursor.fetchall() # cursor 메모리에 담긴 결과를 한 번에 row 변수에 담는다. emp15 = pd.DataFrame(row) # row 데이터를 판다스 데이터프레임으로 구성합니다. colname = cursor.description # 오라클 db 에서 컬럼명에 대한 정보를 수집 col = [] for i in colname: col.append(i[0].lower()) # 컬럼명을 소문자로 변경해서 append 시킵니다. emp15.columns = col display(emp15) |
| import pandas as pd emp15.groupby(['telecom']).empno.count().plot.bar(rot=0) |
| import pandas as pd emp15.groupby(['telecom']).empno.count().plot(kind='pie', autopct='%0.0f%%') |
다음검색