当前位置:网站首页>Astype conversion data type
Astype conversion data type
2022-06-26 04:50:00 【I am a little monster】
astype Method : The generic function , Can be used to dataframe Convert any column in to another type
Common data types are :int integer ;float floating-point ;object/str character string ;category Classified data .
import pandas as pd
import seaborn as sns
tips=sns.load_dataset('tips')# choice seaborn Self contained data set tips
print(tips.dtypes)# see tips The type of each column of data
tips['sex']=tips['sex'].astype(str)# take sex The column is converted to a string type and assigned to sex Column
print(tips.dtypes)
tips['sex_str']=tips['sex'].astype(str)# take sex The column is converted to a string type and assigned to the new column
print(tips.dtypes)The output is as follows :
total_bill float64
tip float64
sex category
smoker category
day category
time category
size int64
dtype: object
[Finished in 1.8s]total_bill float64
tip float64
sex object
smoker category
day category
time category
size int64
dtype: object
[Finished in 1.7s]total_bill float64
tip float64
sex category
smoker category
day category
time category
size int64
sex_str object
dtype: object
[Finished in 1.7s]
边栏推荐
- 【quartz】从数据库中读取配置实现动态定时任务
- Laravel pay payment access process
- Multipass中文文档-移除实例
- Thinkphp6 using kindeditor
- 1.14 learning summary
- Anti withdrawal test record
- Datetime data type ---now() gets the current time, datetime() creation date, performs mathematical operations, and to_ Datetime() converts to date type and extracts various parts of date
- 基础查询
- 2.22.2.14
- Multipass中文文档-设置驱动
猜你喜欢

Why do many Shopify independent station sellers use chat robots? Read industry secrets in one minute!

0622-马棕榈跌9%

Svn error command revert error previous operation has not finished; run ‘ cleanup‘ if
![[H5 development] 02 take you to develop H5 list page ~ including query, reset and submission functions](/img/39/64df931d5ec54d7d19ae444fa372ba.jpg)
[H5 development] 02 take you to develop H5 list page ~ including query, reset and submission functions

Multipass Chinese document - setup driver

UWB超高精度定位系统架构图

1.18 learning summary

1.19 learning summary

MySql如何删除所有多余的重复数据

2.22.2.14
随机推荐
"Eight hundred"
Wechat applet exits the applet (navigator and api--wx.exitminiprogram)
Sort query
Differences between TCP and UDP
File upload and security dog
MySql如何删除所有多余的重复数据
mysql高级学习(跟着尚硅谷老师周阳学习)
How can the intelligent transformation path of manufacturing enterprises be broken due to talent shortage and high cost?
Datetime data type ---now() gets the current time, datetime() creation date, performs mathematical operations, and to_ Datetime() converts to date type and extracts various parts of date
Why do many Shopify independent station sellers use chat robots? Read industry secrets in one minute!
1.21 learning summary
22.2.8
2022 talent strategic transformation under the development trend of digital economy
Database design (I)
基础查询
Install Damon database
Navicat connects the pit of shardingsphere sub table and sub library plug-ins
天才制造者:独行侠、科技巨头和AI|深度学习崛起十年
Stm8 MCU ADC sampling function is triggered by timer
Svn correlation