91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Pandas中split()方法如何使用

發布時間:2021-08-11 14:31:03 來源:億速云 閱讀:276 作者:Leah 欄目:云計算

這期內容當中小編將會給大家帶來有關 Pandas中split()方法如何使用,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

split()正序分割列;rsplit()逆序分割列
Series.str.split(pat=None, n=-1, expand=False)
參數:
pat : 字符串,默認使用空白分割.
n : 整型,默認為-1,既使用所有的分割點分割
expand : 布爾值,默認為False.如果為真返回數據框(DataFrame)或復雜索引(MultiIndex);如果為True,返回序列(Series)或者索引(Index).
return_type : 棄用,使用spand參數代替
返回值:
split : 參考expand參數

例子:
將一下列表按第一個空格分割成兩個列表,列表的名稱分別是“Property”和“Description”

Property Description
year The year of the datetime
month The month of the datetime
day The days of the datetime
hour The hour of the datetime
minute The minutes of the datetime
second The seconds of the datetime
microsecond The microseconds of the datetime
nanosecond The nanoseconds of the datetime
date Returns datetime.date (does not contain timezone information)
time Returns datetime.time (does not contain timezone information)
dayofyear The ordinal day of year
weekofyear The week ordinal of the year
week The week ordinal of the year
dayofweek The numer of the day of the week with Monday=0, Sunday=6
weekday The number of the day of the week with Monday=0, Sunday=6
weekday_name The name of the day in a week (ex: Friday)
quarter Quarter of the date: Jan=Mar = 1, Apr-Jun = 2, etc.
days_in_month The number of days in the month of the datetime
is_month_start Logical indicating if first day of month (defined by frequency)
is_month_end Logical indicating if last day of month (defined by frequency)
is_quarter_start Logical indicating if first day of quarter (defined by frequency)
is_quarter_end Logical indicating if last day of quarter (defined by frequency)
is_year_start Logical indicating if first day of year (defined by frequency)
is_year_end Logical indicating if last day of year (defined by frequency)
is_leap_year Logical indicating if the date belongs to a leap year
import pandas as pd
df=pd.read_excel("C:/Users/Administrator/Desktop/New Microsoft Excel 工作表.xlsx")#讀取工作表df["Property"],df["Description"]=df["Property Description"].str.split(" ",n=1).str#按第一個空格分割df.drop("Property Description",axis=1,inplace=True)#刪除原有的列df.to_csv("C:/Users/Administrator/Desktop/New Microsoft Excel 工作表.csv",index=False)#保存為csv,并刪除索引

結果如下圖所示:

PropertyDescription
yearThe year of the datetime
monthThe month of the datetime
dayThe days of the datetime
hourThe hour of the datetime
minuteThe minutes of the datetime
secondThe seconds of the datetime
microsecondThe microseconds of the datetime
nanosecondThe nanoseconds of the datetime
dateReturns datetime.date (does not contain timezone information)
timeReturns datetime.time (does not contain timezone information)
dayofyearThe ordinal day of year
weekofyearThe week ordinal of the year
weekThe week ordinal of the year
dayofweekThe numer of the day of the week with Monday=0, Sunday=6
weekdayThe number of the day of the week with Monday=0, Sunday=6
weekday_nameThe name of the day in a week (ex: Friday)
quarterQuarter of the date: Jan=Mar = 1, Apr-Jun = 2, etc.
days_in_monthThe number of days in the month of the datetime
is_month_startLogical indicating if first day of month (defined by frequency)
is_month_endLogical indicating if last day of month (defined by frequency)
is_quarter_startLogical indicating if first day of quarter (defined by frequency)
is_quarter_endLogical indicating if last day of quarter (defined by frequency)
is_year_startLogical indicating if first day of year (defined by frequency)
is_year_endLogical indicating if last day of year (defined by frequency)
is_leap_yearLogical indicating if the date belongs to a leap year

上述就是小編為大家分享的 Pandas中split()方法如何使用了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

辽阳市| 会东县| 天津市| 乌审旗| 秦安县| 奉贤区| 璧山县| 观塘区| 尚志市| 沂南县| 分宜县| 齐齐哈尔市| 新蔡县| 德兴市| 长岭县| 永平县| 武陟县| 辽阳县| 夏邑县| 沈丘县| 冀州市| 清远市| 凌云县| 吉林省| 武强县| 稻城县| 临汾市| 安远县| 横山县| 东安县| 尼木县| 乐都县| 沿河| 嘉义市| 准格尔旗| 阳东县| 石棉县| 西昌市| 巴塘县| 许昌县| 肥西县|