-
肥皂起泡泡
此处不需要使用zip,只需遍历列表,拆分每个元素并将其存储为元组即可。l = [ '1 2', '7 8', '10 7'][tuple(int(i) for i in numbers.split()) for numbers in l]#[(1, 2), (7, 8), (10, 7)]
-
交互式爱情
试试这个,df.columnsList.apply(lambda x :
[tuple(map(int, x.split())) for x in "1 2, 7 8, 10 7".split(",")])输出,0 [(1, 2), (7, 8), (10, 7)]
Name: columnsList, dtype: object
-
慕斯709654
您可以将字符拆分后映射到整数,然后将映射对象转换为元组:temp = df['columnList'].str.split(',')result = [tuple(map(int, num.split())) for num in temp]print(result)# [(1, 2), (7, 8), (10, 7)]