전체 글140 [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. [Apps script] Google Spreadsheet에서 slack 메시지 보내기 업무용으로 구글 스프레드 시트에서 기록된 데이터를 슬랙으로 쏴주고 싶었다. 그런데 자꾸 invalid_payload 에러가 나서 한참을 해맸다. function myFunction() { var slackUrl = "https://hooks.slack.com/services/주소" ; var contents = 내용; var msg = {"text" : contents }; var option = { 'method' : 'post', 'ContentType':'application/json', 'payload': JSON.stringify(msg) }; Logger.log(option) UrlFetchApp.fetch(slackUrl, option); } 처음 찾아본 레퍼런스에서 이것저건 수정하긴 했는데.. 2022. 11. 15. [excel] 자료해석/NCS 분수비교(나눗셈) 어림산 - 문제 랜덤 생성 시트 자료해석/수리영역의 핵심은 어림산? PSAT 자료해석이나 NCS 수리영역에서 기본 중 하나는 어림산이라 생각한다. 기본적으로 이 시험들의 목적은 짧은 시간에 얼마나 많은 양의 정보를 필요한 만큼 흡수하고 올바른 결론에 도달하는지 보는지이기에 우선은 속도다. 그래서 문제푸는 시간을 1초라도 아껴야하고, 쓸데없이 세밀한 계산보다는 어림산이 기본 스킬이 된다. 어림산은 연습 없이 안된다! 그러나 대부분의 사람은 이런 계산에 익숙하지 않다. 그래서 훈련이 필요한데 다행히도 이러한 훈련에 적합한 여러가지 도구들이 있다. 한창 NCS 준비할 때는 매일 아침마다 비타민이라는 걸 풀었던 기억이 난다. 그런데 풀다보면 똑같은 문제 페이지도 있고, 자리수나 난이도가 비슷하다보니 지루한 느낌도 있었다. 그래서 만든 분수비교.. 2022. 11. 7. HackerRank SQL - Higher Than 75 Marks Query the Name of any student in STUDENTS who scored higher than Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID. Input Format The STUDENTS table is described as follows: The Name column only contains uppercase (A-Z) and lowercase (a.. 2022. 11. 1. HackerRank SQL - The Blunder Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's key was broken until after completing the calculation. She wants your help finding the difference between her miscalculation (using salaries with any zeros removed), and the actual average salary. Write a query calculating the amount of error (i.e.: avera.. 2022. 11. 1. [MySQL] 정규 표현식(instr(), like(), replace(), substr()) 정규 표현식이란 정규식 또는 정규 표현식은 문자열에서 일치하는 패턴을 찾아내는 데 쓰이는 형식 언어이다. 정규식에 대한 자세한 내용은 나중에 따로 정리해두겠지만, SQL에서도 쓸 수 있기에 함수만 아래와 같이 정리했다. 정규식 함수 및 연산자 NOT REGEXP 정규식의 부정 REGEXP 문자열이 정규식과 일치하는지 여부 REGEXP_INSTR() 정규식과 일치하는 부분의 문자열의 시작 인덱스 REGEXP_LIKE() 문자열이 정규식과 일치하는지 여부 REGEXP_REPLACE() 문자열이 정규식과 일치하는 부분을 바꾸기 REGEXP_SUBSTR() 문자열이 정규식과 일치하는 부분을 반환 RLIKE 문자열이 정규식과 일치하는지 여부 출처: https://dev.mysql.com/doc/refman/8.0.. 2022. 10. 31. 이전 1 ··· 11 12 13 14 15 16 다음