본문 바로가기

분류 전체보기139

HackerRank SQL - Occupations Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively. Note: Print NULL when there are no more names corresponding to an occupation. Input Format The OCCUPATIONS table is described as follows: Occupation will only contain on.. 2023. 1. 6.
HackerRank SQL - The PADS Generate the following two result sets: Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S). Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascend.. 2023. 1. 3.
[Python] 네이버 플레이스 크롤링(selenium, BS4) 특정 지역의 데이터셋을 가지고 공부해보고 싶은게 있어서 지역 정보가 필요했다. 그런데 무식하게 긁어올 수 없어서 웹크롤러를 만들어보기로 했다. 바로 떠오른 생각은 네이버 지도에서 가져오는 것인데, 이게 생각보다 쉽지 않았다. 그래서 패쓰하고 네이버 플레이스 서비스로 접근했다. (OPEN API도 있었는데 전화번호 정보는 가져오지 못하는 한계가 있었다.) 우선 기본적인 라이브러리를 불러온다. 네이버에서는 일단 크롤링에 대해서 관대하지 않기 때문에 몇 가지 주의사항이 있다. from selenium.webdriver.common.by import By from urllib3.util.retry import Retry from requests.adapters import HTTPAdapter from bs4 .. 2022. 12. 20.
[Python] json 형식 읽기 import json from pandas.io.json import json_normalize json_string = ('json 문자열') 2022. 12. 14.
[Pandas] read_csv / read_excel - csv/excel 파일 읽기 CSV 파일 읽기 pandas에서 DataFrame 형식으로 csv파일을 읽어올 때 다음과 같이 사용한다. import pandas as pd df = pd.read_csv('파일경로/파일명') 주요 파라미터 encoding str, optional 인코딩하여 읽어올 수 있다. 가끔 한글의 경우 깨지는 경우가 있는데 이럴 땐, encoding = 'cp949' 를 붙여준다. 참조) List of Python standard encodings - https://docs.python.org/3/library/codecs.html#standard-encodings Excel 파일 읽기 pandas에서 DataFrame 형식으로 Excel파일을 읽어올 때 다음과 같이 사용한다. import pandas as p.. 2022. 12. 14.
[MySQL] Order by 구문으로 숫자가 정렬되지 않을 때 정수타입(int)의 데이터를 정렬할 때, order by 구문을 써도 컬럼이 정렬되지 않을 때가 있다. 해당 컬럼이 숫자로만 이루어져있다고 해도 데이터 형식이 varchar, 혹은 다른 형식이기 때문이다. 당연히 가격 컬럼은 int 타입일거라 생각했는데, 확인해보니 varchar 타입이었다. 두 가지 해결 방법이 있다. ① CAST 함수를 사용해 타입을 명시적으로 바꿔주는 방법 SELECT id, product_name, unit, price FROM product ORDER BY CAST(price AS INT) ASC; CAST함수를 사용해 형변환을 해주는데 INT 뿐만 아니라 FLOAT 도 된다. ② 묵시적 형변환 SELECT id, product_name, unit, price FROM produ.. 2022. 11. 16.
Weather Observation Station 18 Consider and to be two points on a 2D plane. happens to equal the minimum value in Northern Latitude (LAT_N in STATION). happens to equal the minimum value in Western Longitude (LONG_W in STATION). happens to equal the maximum value in Northern Latitude (LAT_N in STATION). happens to equal the maximum value in Western Longitude (LONG_W in STATION). Query the Manhattan Distance between points and.. 2022. 11. 15.
HackerRank SQL - Type of Triangle Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table: Equilateral: It's a triangle with sides of equal length. Isosceles: It's a triangle with sides of equal length. Scalene: It's a triangle with sides of differing lengths. Not A Triangle: The given values of A, B, and C don't fo.. 2022. 11. 15.