【发布时间】:2018-08-11 18:33:02
【问题描述】:
我想显示 ID 和标签,并按顶部标签升序对它们进行排序。
word_counts = word_tuple.reduceByKey(lambda total, count: total + count)
word_counts.take(30)
[('id,tags', 1),
('"16586898","', 1),
('javascript', 3276),
('data-structures', 48),
('documentation', 1153),
('data-visualization', 10),
('"', 27109),
('"1828522","', 1),
('api', 634),
('console', 19),
('installation', 17),
('glassfish', 5),
('admin', 3),
('"25883048","', 1),
('regex', 500),
('bash', 375),
('sed', 56),
('"1879493","', 1),
【问题讨论】:
-
你能解释一下前两行吗?它们不是原生 Python。
-
以下答案之一有帮助吗?如果是这样,请随时接受,或提出问题以澄清。
标签: python python-3.x sorting tuples