原创博文,转载请注明出处!
例子:
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 """
原文地址:https://www.cnblogs.com/wanglei5205/p/8954498.html
时间: 2024-11-13 14:37:48