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

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.

主站蜘蛛池模板: 双流县| 芦山县| 醴陵市| 个旧市| 莱州市| 松阳县| 崇礼县| 信宜市| 花垣县| 连平县| 醴陵市| 聊城市| 大方县| 漯河市| 濉溪县| 内江市| 太仆寺旗| 启东市| 监利县| 神农架林区| 哈巴河县| 宁河县| 宜春市| 正镶白旗| 霍山县| 宝坻区| 广灵县| 平罗县| 周宁县| 乌鲁木齐县| 拉萨市| 永川市| 布尔津县| 南宫市| 丹东市| 封开县| 积石山| 皋兰县| 苏尼特左旗| 濮阳县| 廉江市|