码迷,mamicode.com
首页 > 其他好文 > 详细

【pandas】pandas.Series.str.split()---字符串分割

时间:2018-04-26 19:55:04      阅读:958      评论:0      收藏:0      [点我收藏+]

标签:pac   isp   博文   images   frame   inf   taf   ack   class   

原创博文,转载请注明出处!

本文代码的github地址

技术分享图片

例子:

  1 # -*- coding: utf-8 -*-
  2 # 创建dataframe
  3 import pandas as pd
  4 s = pd.DataFrame([‘a,b,c‘,‘c,d,e‘])
  5 print(s)
  6 """
  7        0
  8 0  a,b,c
  9 1  c,d,e
 10 """
 11 # 字符串拆分--expend = False
 12 temp_expend_False = s[0].str.split(‘,‘)
 13 print(temp_expend_False)
 14 """
 15 0    [a, b, c]
 16 1    [c, d, e]
 17 """
 18 
 19 # 字符串拆分--expend = True
 20 temp_expend_True = s[0].str.split(‘,‘,expand = True)
 21 print(temp_expend_True)
 22 """
 23    0  1  2
 24 0  a  b  c
 25 1  c  d  e
 26 """

【pandas】pandas.Series.str.split()---字符串分割

标签:pac   isp   博文   images   frame   inf   taf   ack   class   

原文地址:https://www.cnblogs.com/wanglei5205/p/8954498.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!