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

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.

主站蜘蛛池模板: 赫章县| 色达县| 龙井市| 涞水县| 繁峙县| 法库县| 阿坝| 普兰县| 衡南县| 大安市| 略阳县| 进贤县| 黄陵县| 湘潭市| 阳城县| 荔浦县| 临海市| 黔西县| 高邑县| 屯门区| 太湖县| 防城港市| 神池县| 姜堰市| 文登市| 连平县| 乐东| 张家港市| 济阳县| 灌阳县| 四会市| 田东县| 平原县| 通州市| 鲜城| 镇沅| 奎屯市| 乳源| 汾西县| 康乐县| 曲麻莱县|