【发布时间】:2020-08-26 20:56:22
【问题描述】:
我已经看过几篇关于此的帖子,但我尝试的每个解决方案要么得到错误,要么帖子与我需要的略有不同。请参阅下面的尝试。
数据框:
col1
[0.7, 0.8, -0.9]
[0.3, 0.7, 0.1]
我希望像这样按升序对该列中每个列表中的元素进行排序:
results
[-0.9, 0.7, 0.8]
[0.1, 0.3, 0.7]
尝试:
#attempt1
#sorts the column based on the first element in the list
#also tried grabbing other columns with [['col1','col2']] at the end but that doesn't work
sorted(df['jaro_sequencer_diff'])
#attempt2
df['col1'].head().sorted(reverse=True)
#AttributeError: 'Series' object has no attribute 'sorted'
有什么想法吗?
【问题讨论】: