2024/05 40

[Python] Pandas 함수 정리

Pandas 불러오기import pandas as pd  데이터를 파일(csv)로 저장to_csv("저장위치/파일명.파일형식") 인덱스에 대해 설정을 해주지 않으면 기본값은 inedx= True 로인덱스가 컬럼의 형태로 저장이 될 수 있다.ex) unnamed 컬럼 생성data.to_csv("tips_data.csv", index=True) index 의 값을 False 로 설정해주면 인덱스 컬럼형태는 나오지 않음data.to_csv("tips_data.csv", index=False) * 저장할 때 인덱스 값을 설정하지 않았어도 불러올 때 인덱스컬럼을 제외하는 방법도 있다.df = pd.read_csv("tips_data.csv",index_col=0)df  데이터프레임 생성pd.DataFrame()d..

개인공부 2024.05.09

2024-05-08

Today1. SQL 코드카타 1문제(88번)2. 파이썬 300제(219~250)3. 파이썬 총 정리 세션 수강Today I Learned SQL 테이블 3개 join 후 출력하기https://leetcode.com/problems/students-and-examinations/description/ SELECT a.student_id, a.student_name, b.subject_name, COUNT(c.subject_name)FROM students AS aLEFT JOIN examinations AS b ON a.student_id = b.student_idLEFT JOIN subjects AS c ON b.subject_name = c.subject_nameGROUP BY 1,3값이 출력되긴 했..

TIL 2024.05.08

2024-05-07

Today1. SQL 코드카타 1문제(87번)2. 파이썬 300제(151~218) Today I Learned SQL SELECT name, bonusFROM employee AS eLEFT JOIN bonus AS bON e.empid = b.empidWHERE b.bonus # bonus 가 1,000 보다 낮은 직원을 구한다면IS NULL 을 사용하여 받지 못한 직원도 고려해서 출력해야 한다. Python isupper()# 대문자면 True , 소문자면 False capitalize() # 문자열에서의 첫 글자를 대문자로 변환, 리스트는 X리스트 = ['dog', 'cat', 'parrot']for i in 리스트: a = i[0] b = a.upper() print(b+i[1:]..

TIL 2024.05.07

2024-05-03

Today1. SQL 코드카타 1문제(86번)2. 파이썬 300제(126~150)3. 파이썬 개인과제 해설 강의 Today I Learned SQL self join 을 이용한 조건 출력https://lyj-01.tistory.com/132 1661. Average Time of Process per MachineThere is a factory website that has several machines each running the same number of processes. Write a solution to find the average time each machine takes to complete a process. The time to complete a process is the lyj-..

TIL 2024.05.03

3주차[2024-04-29 ~ 05-03]

FACTS 이번주차는 파이썬 집중학습 주차였다.월요일에는 개인과제가 주어지기 전 지급받은 강의 중 어려웠던 부분을 복습하는 시간을 가졌다.화요일 받게된 개인과제는 강의내용을 총망라한 질문들이었고, 튜터님과의 멘토링을 하며 제출기한안에 무사히 제출할 수 있었다.금요일 오후, 튜터님께서 개인과제해설에 관하여 강의를 해주셨다.내가 풀었던 방식이 아닌 새로운 방식을 알게되어 신기했다!튜터님께서 참고자료로 주셨던 위키독스의 파이썬 예제 300제를 풀었다. 함수 사용법을 물어보는 기초문제들이 많아 배웠던 것들을 정리하기에 좋았다.SQL도 너무 놓지 않기 위해 매일 1문제씩 코드카타를 하고, 지난주 ADsP 강의 정리가 다 끝나지 않았기 때문에 주말동안마무리정리를 하였다. FEELINGS 사전캠프 기간 중 파이썬 코..

WIL 2024.05.03

1661. Average Time of Process per Machine

There is a factory website that has several machines each running the same number of processes. Write a solution to find the average time each machine takes to complete a process. The time to complete a process is the 'end' timestamp minus the 'start' timestamp. The average time is calculated by the total time to complete every process on the machine divided by the number of processes that were ..

SQL 코드카타 2024.05.03

2024-05-02

Today1. SQL 코드카타(85번)2. 파이썬 300제(121~125)3. 파이썬 개인과제 제출4. 파이썬 심화함수 강의 복습 Today I Learned SQL 같은 테이블에서의 JOIN이 필요했던 문제https://lyj-01.tistory.com/129 197. Rising TemperatureWrite a solution to find all dates' Id with higher temperatures compared to its previous dates (yesterday).Return the result table in any order.The result format is in the following example.SELECT w1.idFROM weather AS w1JOIN wea..

TIL 2024.05.02

파이썬 개인 과제

문제 1: 데이터 불러오기 타이타닉 데이터를 불러온 다음 df라는 변수에 담고 데이터의 내용을 확인하세요.from google.colab import drivedrive.mount('/content/drive')root = "/content/drive/MyDrive/스파르타파이썬"file_address = root + "/train.csv"import pandas as pddf = pd.read_csv(file_address)display(df)  문제 2: 생존자 수 계산 타이타닉 전체 생존자 수와 사망자 수를 계산하고 출력하세요.생존자=[]사망자=[]total=df['Survived']for i in df['Survived']: if i == 1: 생존자.appen..

개인공부 2024.05.02

2024-05-01

Today1. SQL 코드카타(84번)2. 파이썬 개인 과제(궁금한점, 11번12번 풀이)3. 파이썬 300제(81~120)Today I Learned Python zip 함수 주의사항# 인자의 길이를 똑같이 해야 함# 길이가 다르다면 가장 짧은 길이의 인자에 맞춰지고 나머지는 버려지게 된다# 아래 두 개의 튜플을 하나의 딕셔너리로 변환하라. #keys를 키로, vals를 값으로 result 이름의 딕셔너리로 저장한다.keys = ("apple", "pear", "peach")vals = (300, 250, 400)for x,y in zip(keys,vals): # 마지막값만 들어감 resultresult이렇게 코드를 짤 경우 x,y  가 계속 덮어씌워지면서 결국에는 마지막 값인 {'peach..

TIL 2024.05.01