当前位置:网站首页>Introduction to data analysis 𞓜 kaggle Titanic mission (III) - > explore data analysis
Introduction to data analysis 𞓜 kaggle Titanic mission (III) - > explore data analysis
2022-04-23 10:33:00 【Ape knowledge】
Series index : Introduction to data analysis | kaggle Titanic mission
One 、 Exploratory data analysis
Mainly introduce the use of Pandas Sort 、 Arithmetic calculation and calculation description function describe() Use .
(1) Create a simulation data
# Build a digital DataFrame data
frame = pd.DataFrame(np.arange(8).reshape((2, 4)),
index=['2', '1'],
columns=['d', 'a', 'b', 'c'])
frame
pd.DataFrame()
: Create a DataFrame object
np.arange(8).reshape((2, 4))
: Generate a two-dimensional array (2*4), First column :0,1,2,3 Second column :4,5,6,7
index=['2, 1]
:DataFrame The index column of the object
columns=['d', 'a', 'b', 'c']
:DataFrame The index line of the object
(2) Sort
frame.sort_values(by='c', ascending=True) #by The parameter points to the column to be arranged ,sacending Point sort method ( Ascending / Descending )
# Let the row index sort in ascending order
frame.sort_index()
# Let the column index sort in ascending order
frame.sort_index(axis=1)
# Sort the column index in descending order
frame.sort_index(axis=1, ascending=False)
# Let any two columns of data be sorted in descending order at the same time
frame.sort_values(by=['a', 'c'], ascending=False)
When sorting two columns , In order , If there are equal numbers in the former , Sort by the next column .
Such as :sort_values(by=['a','c'].ascending = [False, True])
This line means to follow a Arrange in descending order , When a Press the same value in b Ascending order .
(3) utilize Pandas Do arithmetic
frame1_a = pd.DataFrame(np.arange(9.).reshape(3, 3),
columns=['a', 'b', 'c'],
index=['one', 'two', 'three'])
frame1_b = pd.DataFrame(np.arange(12.).reshape(4, 3),
columns=['a', 'e', 'c'],
index=['first', 'one', 'two', 'second'])
frame1_a
# take frame_a and frame_b Add additivity
frame1_a + frame1_b
【 remind 】 Two DataFrame Add up , Will return a new DataFrame, The corresponding row and column values are added , If there is no corresponding, it will become null NaN.
Of course ,DataFrame There are many arithmetic operations , Such as subtraction , Division, etc , Interested students can see 《 utilize Python Data analysis 》 The fifth chapter Align arithmetic operations with data part , Find more relevant learning materials on the Internet .
# call describe function , Observe frame2 Basic information of data
frame2.describe()
''' count : Sample data size mean : The average of the sample data std : Standard deviation of sample data min : Minimum value of sample data 25% : Sample data 25% The value at the time of 50% : Sample data 50% The value at the time of 75% : Sample data 75% The value at the time of max : Maximum value of sample data '''
''' Look at the Titanic dataset The fare The basic statistics of this column '''
text[' The fare '].describe()
Introduction to data analysis | kaggle Titanic mission The series is constantly updated , welcome
Like collection
+Focus on
Last one : Introduction to data analysis | kaggle Titanic mission ( Two )—>pandas Basics
Next : Introduction to data analysis | kaggle Titanic mission ( Four )—> Data cleaning and feature processing
My level is limited , Please comment and correct the deficiencies in the article in the comment area below ~If feelings help you , Point a praise Give me a hand ~
Share... From time to time Interesting 、 Have a material 、 Nutritious content , welcome Subscribe to follow My blog , Looking forward to meeting you here ~
版权声明
本文为[Ape knowledge]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230619310794.html
边栏推荐
猜你喜欢
C语言——自定义类型
部署jar包
【leetcode】102. Sequence traversal of binary tree
Swagger2 自定义参数注解如何不显示
Net start MySQL MySQL service is starting MySQL service failed to start. The service did not report any errors.
Sim Api User Guide(6)
mysql同一个表中相同数据怎么合并
101. Symmetric Tree
Reading integrity monitoring techniques for vision navigation systems - 3 background
SSH uses private key to connect to server without key
随机推荐
JVM——》常用参数
Contact between domain name and IP address
SSH利用私钥无密钥连接服务器踩坑实录
SQL server query database deadlock
Yarn core parameter configuration
Shell script interaction free
SQL Server 递归查询上下级
Jerry sometimes finds that the memory has been tampered with, but there is no exception. How should he find it? [chapter]
JUC concurrent programming 09 -- source code analysis of condition implementation
【leetcode】107.二叉树的层序遍历II
242、有效字母异位词(哈希表)
Introduction to wechat applet, development history, advantages of applet, application account, development tools, initial knowledge of wxml file and wxss file
C#和数据库连接中类的问题
Chapter II in memory architecture (im-2.2)
997、有序数组的平方(数组)
Realizing data value through streaming data integration (5) - stream processing
Common SQL statements of DBA (6) - daily management
209、长度最小的子数组(数组)
shell脚本免交互
【省选联考 2022 D2T1】卡牌(状态压缩 DP,FWT卷积)