Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Sorts this RDD, which is assumed to consist of (key, value) pairs

# sortByKey(ascending=True, numPartitions=None, keyfunc= <function <lambda> at 0x7fc35dbcf848>)
tmp = [('a', 1), ('b', 2), ('1', 3), ('d', 4), ('2', 5)]
sc.parallelize(tmp).sortByKey().first()
# ('1', 3)
sc.parallelize(tmp).sortByKey(True, 1).collect()
# [('1', 3), ('2', 5), ('a', 1), ('b', 2), ('d', 4)]
sc.parallelize(tmp).sortByKey(True, 2).collect()
# [('1', 3), ('2', 5), ('a', 1), ('b', 2), ('d', 4)]
tmp2 = [('Mary', 1), ('had', 2), ('a', 3), ('little', 4), ('lamb', 5)]
tmp2.extend([('whose', 6), ('fleece', 7), ('was', 8), ('white', 9)])
sc.parallelize(tmp2).sortByKey(True, 3, keyfunc=lambda k: k.lower()).collect()
# [('a', 3), ('fleece', 7), ('had', 2), ('lamb', 5),...('white', 9)]
Comment

PREVIOUS NEXT
Code Example
Python :: Compute the variance of this RDD’s elements 
Python :: how to find mean media and mode python 
Python :: new listnode(0) meaning 
Python :: Filters rows using the given condition 
Python :: django voice lib 
Python :: Limits the result count to the number specified 
Python :: save python dic 
Python :: how to xor two element in python 
Python :: python pygeoip example 
Python :: python write request must be str not bytes 
Python :: Return the indices of the bins 
Python :: introduction python graphviz simple graph examples 
Python :: idwt pywt 
Python :: text input tkinter 
Python :: cannot import name Glib 
Python :: download viper for python ubutunu 
Python :: does the queen brush her teeth 
Python :: multiplication table with three lines of code in python 
Python :: what is meant by seasonality_mode in prophet 
Python :: saaaaaaaaaaaaa 
Python :: pandas dataframe mask all entries which include a string 
Python :: ev. DJANGO CREATE ACC 
Python :: salir programa python 
Python :: zipfian distribution python 
Python :: MyTestCase 
Python :: python print statement 
Python :: python code for diamond with gap between odd rows 
Python :: change size of image and fir it into numpy array opencv 
Python :: Use Python to calculate (((1+2)*3)/4)^5 
Python :: Classical Cryptography: Using Classical Ciphers with pycipher. 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =