官术网_书友最值得收藏!

applymap

We've looked at manipulating columns and explained how to work with rows, but suppose you'd like to perform a function across all data cells in your DataFrame. This is where applymap is the correct tool. Let's take a look at an example:

Using applymap function

Here, we called applymap on our DataFrame in order to get the log of every value (np.log() utilizes the NumPy library to return this value), if that value is of the float type. This type checking prevents returning an error or a float for the species or wide petal columns, which are string and integer values respectively. Common uses of applymap include transforming or formatting each cell based on meeting a number of conditional criteria.

主站蜘蛛池模板: 祁连县| 浦北县| 五峰| 四平市| 马鞍山市| 吉隆县| 武鸣县| 台山市| 汤阴县| 石泉县| 太白县| 宽城| 博乐市| 香港 | 临湘市| 民勤县| 乌鲁木齐市| 晋州市| 双流县| 宿州市| 布尔津县| 平江县| 汉阴县| 兰西县| 冕宁县| 永吉县| 乌兰察布市| 南皮县| 贡嘎县| 儋州市| 阜新市| 广宁县| 仁布县| 南岸区| 区。| 武鸣县| 靖边县| 新巴尔虎左旗| 鲁山县| 大丰市| 安溪县|