Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python将csv列排序为整数_Python_Sorting_Csv - Fatal编程技术网

python将csv列排序为整数

python将csv列排序为整数,python,sorting,csv,Python,Sorting,Csv,尝试对csv整数列进行排序,但它按字母顺序排序 这是按字母顺序排序,而不是按数字排序 sortedChanels = sorted(reader, key=operator.itemgetter(4), reverse=False) 尝试 sortedChanels = sorted(reader, key=lambda t: int(t(4))) 出错 TypeError:“列表”对象不可调用 只需清除csv列是一个int,但被排序为alpha。看起来t是一个列表-您的t(4)应该是t[4

尝试对csv整数列进行排序,但它按字母顺序排序

这是按字母顺序排序,而不是按数字排序

sortedChanels = sorted(reader, key=operator.itemgetter(4), reverse=False)
尝试

sortedChanels = sorted(reader, key=lambda t: int(t(4)))
出错

TypeError:“列表”对象不可调用


只需清除csv列是一个int,但被排序为alpha。看起来
t
是一个列表-您的
t(4)
应该是
t[4]
只需清除csv列是一个int,但被排序为alpha。看起来
t
是一个列表-您的
t(4)
应该是
t[4]
只是为了澄清csv列是一个int,但被排序为alpha。看起来
t
是一个列表-你的
t(4)
应该是
t[4]
只是为了澄清csv列是一个int,但被排序为alpha。看起来
t
是一个列表-你的
t(4)
应该是
t[4]
sortedChanels = sorted(reader, key=lambda row: int(row[4]), reverse=False)