Excel文件:
5432 321 9870 import pandas as pd file = 'read.xlsx' df1 = pd.read_excel(file) print(df1)
我想将数字中的数字排序为
2345 1234 0789
zysjyyx41#
使用列表解析将值转换为string,其中sorted:
string
sorted
#read excel file without header, so column is 0 df1 = pd.read_excel(file, header=None) df1['new'] = [''.join(sorted(str(x))) for x in df1[0]] print (df1) col 0 2345 1 1234 2 0789
1条答案
按热度按时间zysjyyx41#
使用列表解析将值转换为
string
,其中sorted
: