Python(58)
-
[LeetCode] Pandas / 2881. Create a new column
문제 링크https://leetcode.com/problems/create-a-new-column/description/ 문제 코드import pandas as pddef createBonusColumn(employees: pd.DataFrame) -> pd.DataFrame: employees['bonus'] = employees['salary']*2 return employees
2024.07.08 -
[LeetCode] Pandas / 2880. Select Data
문제 링크https://leetcode.com/problems/select-data/description/ 문제 코드import pandas as pddef selectData(students: pd.DataFrame) -> pd.DataFrame: return students[students.student_id == 101][["name", "age"]]
2024.07.08 -
[LeetCode] Pandas / 2879. Display the first three rows
문제 링크https://leetcode.com/problems/display-the-first-three-rows/description/ 문제 코드import pandas as pddef selectFirstRows(employees: pd.DataFrame) -> pd.DataFrame: return employees.head(3)
2024.07.08 -
[LeetCode] Pandas / 2878. Get the size of a DataFrame
문제 링크https://leetcode.com/problems/get-the-size-of-a-dataframe/ 문제 코드import pandas as pddef getDataframeSize(players: pd.DataFrame) -> List[int]: return [players.shape[0], players.shape[1]]
2024.07.08 -
[LeetCode] Pandas / 2877. Create a DataFrame from List
문제 링크https://leetcode.com/problems/create-a-dataframe-from-list/description/ 문제 코드import pandas as pddef createDataframe(student_data: List[List[int]]) -> pd.DataFrame: return pd.DataFrame(student_data, columns=['student_id', 'age'])
2024.07.08 -
[프로그래머스] Python / 배열의 유사
문제 링크 https://school.programmers.co.kr/learn/courses/30/lessons/120903 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 코드 def solution(s1, s2): count = 0 count += len(set(s1)&set(s2)) return count 1. 배열끼리 비교를 쉽게 하기 위해서 s1과 s2를 각각 집합 자료형으로 만들어주는 set() 함수를 사용한다. 2. len()함수를 1번에 씌운다. 개수가 곧 배열의 길이와 같기 때문이다. 3. += 대입연산자를 count에 적용해서 값을..
2024.03.22