What do you want to save?
Add Code snippet
New code examples
-
Python 2021-09-16 18:52:04
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).... Add solution -
Python 2021-09-16 17:14:01
python vernam cipher
vernam_dict = dict((i, chr(i + 96)) for i in range(1, 27)) # Vernam by replacing char of plain by char(ord(sum of plain and key)) def vernam_encrypt(plain, key): plain = plain.lower() ckey = ''.join([(key[i % len(key)]) for i in range(len(list(pla... Add solution -
Python 2021-09-14 15:07:02
remove columns that contain string pandas
import pandas as pd import numpy as np array=np.random.random((2,4)) df=pd.DataFrame(array, columns=('Test1', 'toto', 'test2', 'riri')) print df Test1 toto test2 riri 0 0.923249 0.572528 0.845464 0.144891 1 0.020438 0.332540... Add solution -
Python 2021-09-10 09:44:03
how to give multiple option to the user and ask the same question again and again until the user tells one of the options
while True: data = input("Please enter a loud message (must be all caps): ") if not data.isupper(): print("Sorry, your response was not loud enough.") continue else: #we're happy with the value given... Add solution -
Python 2021-09-06 19:01:04
start and end index in python
import re # matches_position_start will be a list of starting index positions matches_start = re.finditer(word.lower(), string.lower()) matches_position_start = [match.start() for match in matches_start] # matches_position_end will be a list of ending in... Add solution -
Python 2021-09-05 07:11:03
face detection python
import face_recognition import os import cv2 KNOWN_FACES_DIR = 'known_faces' UNKNOWN_FACES_DIR = 'unknown_faces' TOLERANCE = 0.6 FRAME_THICKNESS = 3 FONT_THICKNESS = 2 MODEL = 'cnn' # default: 'hog', other one can be 'cnn' - CUDA accelerated (if availa... Add solution