[PYTHON] Illustrated pandas function application process

DataFrame and Series

The difference between having multiple columns or not. DataFrame [" column name "] returns Series.

q1.png

Series.map () and DataFrame.applymap ()

map () and ʻapplymap ()are element-by-element applications. ForSeries.map (), specify na_action =" ignore "when applying to a table with NaN. Also, as an additional function, if you enter dictionary type orSeries instead of function, you can replace" NY "to" New York "(not in DataFrame.applymap () `).

q2.png q3.png

Series.apply () and DataFrame.apply ()

DataFrame.apply () is processed for each item or column (select with ʻaxis`). For example, use this when you want to use multiple columns of elements when processing each item.

There are few reasons to use Series.apply () over Series.map () except in special cases.

q4.png q6.png q5.png

Recommended Posts

Illustrated pandas function application process
Python application: Pandas # 3: Dataframe
Python application: Pandas Part 1: Basic
Python application: Pandas Part 2: Series
Julia Quick Note [10] Function (2) Application
Function synthesis and application in Python