본문 바로가기

분류 전체보기

(150)
[pandas] Cut rows based on integer To cut rows based on integer and convert its type into category, there are two method : pd.cut() : Set boundary while we cut rows based on integer pd.qcut() : Set automatic boundary while we cut rows based on integer. After using this method, final datatype of columns become Categorical class. bins = [1, 20, 30, 50, 70, 100] labels = ["미성년자", "청년", "중년", "장년", "노년"] titanic['age_cat'] = pd.cut(t..
[pandas] Set options Pandas has an options API configure and customize global behavior related to DataFrame display, date behavior and more. The most using options for dataframe are below : import pandas # Max column views pd.options.display.max_columns = 999 # Suppress scientific notation pd.set_option('display.float_format', lambda x: '%.5f' % x)
[folium] Visualization Map on Python 1. What is Folium? Folium makes it easy to visualize data that's been manipulated in Python on an interactive leaflet map. It enables both the binding of data to a map for choropleth visualizations as well as passing rich vector/raster/HTML visualizations as markers on the map. 2. How to use Folium Step 1 : Import library folium import folium Step 2 : Set the center of map's frame To start map w..
[Syntax] See Records with NULL In MySQL, NULL values excluded automatically while we querying data. So to see values with all NULL values, we have to add more condition to original query statement. SELECT name FROM customer WHERE referee_id 2 OR referee_id IS NULL; Source from : https://www.w3schools.com/mysql/mysql_null_values.asp https://www.w3schools.com/mysql/mysql_where.asp
[Syntax] DELETE 1. What is DELETE Statement? DELETE is a Data Manipulation Language command, DML command and is used to remove tuples/records from a relation/table. 2. Syntax DELETE FROM table WHERE [conditions]; 3. Error : You can't specify target table When we use subquery in DELTE statement, there is error called : you can't specify target table. The reason why this error raised is because of feature of MySQ..
[heapq] Implementing Binary Heap in Python 1. What is Binary Heap? A Binary Heap is a heap, a tree which obeys the property that the root of any tree is greater than or equals to all its children. The primary use of such a data structure is to implement a priority queue. 2. Implementing Binary Max Heap class PriorityQueue: def __init__(self): self.queue = [] def _heapify(self, n, i): largest = i l = 2 * i + 1 r = 2 * i + 2 if l < n and s..
[queue] Implementing Priority Queue in Python 1. What is Priority Queue? A Priority Queue is a special type of queue in which each element is associated with a priority value. And, elements are served on the basis of their priority. Generally, the value of the element itself is considered for assigning the priority. For example, the element with the highest value is considered the highest priority element. 2. Implementing Priority Queue cla..
[Syntax] Exception 1. Exception Statement 1.1 try - except statement If there is any error while executing codes under try statement, then code under except statement will execute. There are three types of try - except statement. try - except : Codes under except statement will execute whatever error it is. try - except [Raised Error] : Codes under statement except will execute when error is in written case. try -..
[beautifultable] Print List in Table Format 1. What is BeautifulTable? This package provides BeautifulTable Class for easily printing tabular data in a visually appealing format to a terminal. Features included but not limited to : Full customization of the look and the feel of the table Build the table as you wish, by adding rows, or by columns or even mixing both these approaches. Full support for colors using ANSI sequences or any libr..
[beautifulsoup] Web Scraping 1. What is Web Scraping Web Scraping, Web Harvesting, Web Extraction is data scraping used for extracting data from websites. The web scraping software may directly access the World Wide Web using the Hyper Transfer Protocol or a web browser. While web scraping can be done manually by a software user, the term typically refers to automated processes implemented using a bot or web scraper 2. How ..