Article From:https://www.cnblogs.com/Virtual-Z/p/9684097.html

In this section, we are going to learn how to manipulate and manipulate data:
1.Map

MapThe method works for sequential data, so we’ll use it in our chestnuts to transform a column in the data box. When we think the name of the category is too long, we want to replace it, then we can use the Map function:

We ran the Map function in the column of Class to replace the original string.

2.Apply

We continue to use the iris_data data data to add a new column to this data, that is, when the petal width exceeds the average, we determine that it is a wide petal, expressed in 1, otherwise expressed in 0:

First, the average value of Petal Width is calculated.

Next we begin to classify them:

The above is the use of apply on the column. Let’s see how to use it in the data frame.

Note here that axis = 1 operates on rows, because we operate on this data box, so we need to add this condition to continue execution.

3.Applymap

When we want to operate the data frame as a whole, we can use this function:

This line of code indicates that we called the applymap function on the data box, and if a value is of float type, the logarithm of that value is returned, so we can apply the mapIt is regarded as changing or formatting each unit according to certain criteria.

4.Groupby

Group data based on some selected categories:

The system divides the data according to categories, and provides the mean value of each feature.

Use.Describe () to get all the statistical information.

groupbyIs the difficulty is also the key, in the future encounter will also focus on the blog to record ideas and practices!