[Python] 100 knocks on data science (structured data processing) 018 Explanation

Youtube Video commentary is also available.

problem

P-018: Sort the customer data frame (df_customer) by date of birth (birth_day) in ascending order, and display all the first 10 items.

answer

code


df_customer.sort_values('birth_day', ascending=False).head(10)

output

customer_id customer_name gender_cd gender birth_day age postal_cd address application_store_cd application_date status_cd
15639 CS035114000004 Misato Omura 1 Female 2007-11-25 11 156-0053 Sakura, Setagaya-ku, Tokyo********** S13035 20150619 6-20091205-6
7468 CS022103000002 Fukuyama Hajime 9 unknown 2007-10-02 11 249-0006 Zushi, Zushi City, Kanagawa Prefecture********** S14022 20160909 0-00000000-0
10745 CS002113000009 Mayuko Shibata 1 Female 2007-09-17 11 184-0014 Nukuiminami-cho, Koganei-shi, Tokyo********** S13002 20160304 0-00000000-0
19811 CS004115000014 Kyoko Matsui 1 Female 2007-08-09 11 165-0031 Kamisaginomiya, Nakano-ku, Tokyo********** S13004 20161120 1-20081231-1
7039 CS002114000010 Haruka Yamauchi 1 Female 2007-06-03 11 184-0015 Nukui Kitamachi, Koganei City, Tokyo********** S13002 20160920 6-20100510-1
3670 CS025115000002 Natsuki Koyanagi 1 Female 2007-04-18 11 245-0018 Kamiiida-cho, Izumi-ku, Yokohama-shi, Kanagawa********** S14025 20160116 D-20100913-D
12493 CS002113000025 Hirosue Manami 1 Female 2007-03-30 12 184-0015 Nukui Kitamachi, Koganei City, Tokyo********** S13002 20171030 0-00000000-0
15977 CS033112000003 Miki Nagano 1 Female 2007-03-22 12 245-0051 Nase-cho, Totsuka-ku, Yokohama-shi, Kanagawa********** S14033 20150606 0-00000000-0
5716 CS007115000006 Fukuoka Shun 1 Female 2007-03-10 12 285-0845 Nishishizu, Sakura City, Chiba Prefecture********** S12007 20151118 F-20101016-F
15097 CS014113000008 Rio Yaguchi 1 Female 2007-03-05 12 260-0041 Higashichiba, Chuo-ku, Chiba City, Chiba Prefecture********** S12014 20150622 3-20091108-6

Commentary

** ・ It is a method to sort data in Pandas DataFrame / Series. -Use when you want to sort the information in ascending or descending order. -'Sort_values ()' is a function that sorts the specified character string in ascending or descending order. -In this case, since birth_day is sorted in descending order (= sorted in ascending order), it is described as'sort_values ('birth_day', ascending = False)'. ** **

Recommended Posts

[Python] 100 knocks on data science (structured data processing) 018 Explanation
[Python] 100 knocks on data science (structured data processing) 023 Explanation
[Python] 100 knocks on data science (structured data processing) 030 Explanation
[Python] 100 knocks on data science (structured data processing) 022 Explanation
[Python] 100 knocks on data science (structured data processing) 017 Explanation
[Python] 100 knocks on data science (structured data processing) 026 Explanation
[Python] 100 knocks on data science (structured data processing) 016 Explanation
[Python] 100 knocks on data science (structured data processing) 024 Explanation
[Python] 100 knocks on data science (structured data processing) 027 Explanation
[Python] 100 knocks on data science (structured data processing) 029 Explanation
[Python] 100 knocks on data science (structured data processing) 015 Explanation
[Python] 100 knocks on data science (structured data processing) 028 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-007 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-006 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-001 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-002 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 021 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-005 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-004 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 020 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 025 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-003 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 019 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 001-010 Impressions + Explanation Link Summary
Try "100 knocks on data science" ①
Getting started with Python with 100 knocks on language processing
Preparing to try "Data Science 100 Knock (Structured Data Processing)"
Challenge 100 data science knocks
Data science 100 knock (structured data processing) environment construction (Windows10)
Data Science Cheat Sheet (Python)
[Python] Notes on data analysis
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 2]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 1]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 3]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 5]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 4]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 6]
Start data science on the cloud
Image processing with Python 100 knocks # 3 Binarization
Image processing with Python 100 knocks # 2 Grayscale
Image processing with Python 100 knocks # 8 Max pooling
I took Udemy's "Practical Python Data Science"
[Python] Various data processing using Numpy arrays
Image processing with Python 100 knocks # 7 Average pooling
Video processing using Python + OpenCV on Mac
Image processing with Python 100 knocks # 9 Gaussian filter
Books on data science to read in 2020
Periodically execute Python Script on AWS Data Pipeline
Folium: Visualize data on a map with Python
[Data science memorandum] Handling of missing values ​​[python]
Try importing MLB data on Mac and Python
TensorFlow: Run data learned in Python on Android
Run Python on Apache to view InfluxDB data
100 language processing knocks (2020): 40
100 language processing knocks (2020): 32
[Python] Challenge 100 knocks! (015 ~ 019)
100 language processing knocks (2020): 35
python image processing
100 language processing knocks (2020): 47
100 language processing knocks (2020): 39
Python on Windows