728x90
반응형
SMALL

문제/Python 13

231129 Python 실기 문제

[문제1] 구구단을 가로로 출력해주세요. for i in range(1, 10): for dan in range(2, 10): print("{} * {} = {}".format(dan, i, dan*i), end='\t') print(' ') [문제2] 감염병_발생현황.csv 데이터를 이용해서 년도별 감염병 발생현황을 bar plot, line plot 을 생성해주세요. import pandas as pd import matplotlib.pyplot as plt from matplotlib import font_manager, rc font_name = font_manager.FontProperties(fname='C:/Windows/Fonts/gulim.ttc').get_name() re('font',..

문제/Python 2023.11.29

231128 Python 문제

import sqlite3 import pandas as pd [문제1] 근무일수가 가장 많은 10위 까지 직원들의 employee_id, last_name, department_name, 근무일수를 출력해 주세요. 단. sqlite를 이용하세요. conn = sqlite3.connect(':memory:') c = conn.cursor() data = pd.read_csv("c:/data/emp.csv") dept_table = pd.read_csv("c:/data/dept.csv") emp_table.to_sql("emp", conn, index=False) dept_table.to_sql("dept", conn, index=False) c.execute("select * from emp") c.fe..

문제/Python 2023.11.28

231127 Python 문제

[문제] 2006년도 홀수달에 입사한 사원들의 정보를 출력해주세요. c.execute('''select * from emp where date(hire_date) between date('2006-01-01') and date('2006-12-31') and strftime("%m", date(hire_date)) %2 != 0''') # 홀수달 c.fetchall() [문제] 년도별 입사한 인원수를 출력해주세요. c.execute("""select strftime('%Y', date(hire_date)), count(*) from emp group by strftime('%Y', date(hire_date))""") c.fetchall() # pandas식 으로 표현 years = pd.read_sql..

문제/Python 2023.11.27

231122 Python 문제

[문제] 년도 분기별 그룹형 막대그래프를 생성해주세요. df = pd.pivot_table(data = emp, index = emp['HIRE_DATE'].dt.year, columns = emp['HIRE_DATE'].dt.quarter, values = 'EMPLOYEE_ID', aggfunc = 'count') df.fillna(0, inplace=True) # ticks ='' 해결방안 → range() 범위 # 방법1) df.plot(kind='bar') plt.legend(labels= [ str(i)+'분기' for i in df.columns ], loc='upper left') plt.xticks(ticks = range(0,8), # 범위 labels= [ str(i)+'분기' for..

문제/Python 2023.11.22

231121 Python 문제

[문제] 입사년도별 총액 급여를 출력해주세요 emp['SALARY'].groupby(emp['HIRE_DATE'].dt.year).sum() [문제] 입사요일별 인원수를 출력해주세요. 단, 한글요일로 출력해주세요 ('월화수목금토일'[0]+'요일') week = emp['EMPLOYEE_ID'].groupby(emp['HIRE_DATE'].dt.dayofweek).count() week.index Series(week.index).apply(lambda arg: '월화수목금토일'[arg]+'요일') week.index = Series(week.index).apply(lambda arg: '월화수목금토일'[arg]+'요일') week # 건수 출력 및 정렬 week = emp['HIRE_DATE'].dt.w..

문제/Python 2023.11.21

231120 Python 문제

[문제] LAST_NAME 에서 a 글자가 두 번이상 나온 LAST_NAME 출력해주세요 emp[emp['LAST_NAME'].str.findall('a').str.len() >= 2] emp.loc[(emp['LAST_NAME'].str.findall('a').str.len() >= 2), ['LAST_NAME']] [문제] 부서이름별 급여의 총액을 출력해주세요 #1) 부서이름별 급여의 총액 dept_sal = emp['SALARY'].groupby(emp['DEPARTMENT_ID']).sum() type(dept_sal) dept_sal.index #2) 조인 result = pd.merge(dept_sal, dept, left_index=True, right_on='DEPARTMENT_ID') r..

문제/Python 2023.11.20

231116 Python 문제

[문제] 여러 숫자를 인수값으로 받아서 합과 평균을 출력하는 aggF함수를 생성하세요. # aggF(1,2,3,4,5,6,7,8,9,10) # 합 : 55 // 평균 : 5.5 # 방법1 def aggF(*arg): # 가변인수 hap = 0 # 누적합 for i in arg: # 반복문 hap += i print("합 : ", hap) print("평균 : ",hap/len(arg)) aggF(1,2,3,4,5,6,7,8,9,10) # 방법2 def aggF(*arg): # 가변인수 hap = 0 # 누적합 cn = 0 # 건수 for i in arg: # 반복문 hap += i cn += 1 print("합 : ", hap) print("평균 : ",hap/cn) aggF(1,2,3,4,5,6,7,8..

문제/Python 2023.11.20
728x90
반응형
LIST