Sort-Dictionary-By-Value

Fri 14 November 2025

title: "Sort Dictionary By Value" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


dict = {
    'one' : 8,
    'two' : 1,
    'three' : 12
}
dict
{'one': 8, 'three': 12, 'two': 1}
import operator


sorted_x = sorted(dict.items(), key=operator.itemgetter(1))
sorted_x
[('two', 1), ('one', 8), ('three', 12)]
type(sorted_x)
list …

Category: basics

Read More

Sort-Map-By-Key

Fri 14 November 2025

title: "Sort Map By Key" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


print('Hello Toronto')
Hello Toronto
def sort_by_key(dict):
    '''
        ::getRemotrAddr
    '''
    '''
    for key, value in sorted(dict.iteritems(), key=lambda(k,v): (v,k)):
        print("%s: %s" % (key, value))
    '''

    for key in sorted(dict.keys()):
        print …

Category: basics

Read More

Sort-Map-By-Value

Fri 14 November 2025

title: "Sort Map by Value" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


def sort_by_value(dict):
    '''

    '''

    age_sorted = sorted(dict.items(), key=lambda x:x[1])

    #print(age_sorted)

    return age_sorted
age = {
        'carl':40,
        'alan':2,
        'bob':1,
        'danny':3
    }
age_sorted = sort_by_value(age)
age_sorted
[('bob', 1), ('alan', 2), ('danny …

Category: basics

Read More

Split-And-Get-First

Fri 14 November 2025

UNDERSCORE = "_"
feature_value_map_for_score = {
  "system_businessname_overlapLevenshtein": 0.5,
  "system_address_overlapLevenshtein": 1.0,
  "system_streetname_overlapLevenshtein": 1.0,
  "system_city_overlapLevenshtein": 1.0,
  "system_zipcode_overlapLevenshtein": 1.0,
  "system_businessname_sorensen": 0.56,
  "system_address_sorensen": 1.0,
  "system_streetname_sorensen": 1.0,
  "system_city_sorensen": 1.0,
  "system_region_sorensen": 1.0,
  "system_houseno_exactMatch": 1.0,
  "system_zipcode_ratcliff": 1.0,
  "system_suiteno_exactMatch": 1.0
}
individual_algo_feature_score_map = {
  "system_businessname": {
    "system_businessname_overlapLevenshtein": 0.5,
    "system_businessname_sorensen": 0.56 …

Category: basics

Read More

Split With Multiple Delim

Fri 14 November 2025

title: "Split with Multiple" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import re
content = "Hey, you - what are you doing here!?"
contents = re.findall(r"[\w']+", content)
contents
['Hey', 'you', 'what', 'are', 'you', 'doing', 'here']
for c in contents:
    print(c)
Hey
you
what
are
you …

Category: basics

Read More

Startswith

Fri 14 November 2025

title: "String Startswith" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


content = "Toronto is awesome"
content.startswith("Toronto")
True


Score: 0

Category: basics

Read More

Static-Decorator

Fri 14 November 2025

title: "Static Decorator" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


class Example:
    name = "Example"

    @staticmethod
    def static():
        print("%s static() called" % Example.name)
class Offspring1(Example):
    name = "Offspring1"
class Offspring2(Example):
    name = "Offspring2"

    @staticmethod
    def static():
        print("%s static() called" % Offspring2.name)
Example.static()
Example static() called
Offspring1 …

Category: basics

Read More

Static-On-The-Fly

Fri 14 November 2025

title: "Static on the fly" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


class Mathematics:

    def addNumbers(x, y):
        return x + y
# create addNumbers static method
Mathematics.addNumbers = staticmethod(Mathematics.addNumbers)
print('The sum is:', Mathematics.addNumbers(5, 10))
The sum is: 15


Score: 5

Category: basics

Read More

Statistics-Simple

Fri 14 November 2025

title: "Statistics Simple" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import statistics
data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5]
print(statistics.mean(data))
1.6071428571428572
print(statistics.median(data))
1.25
print(statistics.variance(data))
1.3720238095238095


Score: 5

Category: basics

Read More

Stock-Graph

Fri 14 November 2025

title: "Stock Graph" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import matplotlib.pyplot as plt
import fix_yahoo_finance as yf
def show_stock(code):
    data = yf.download(code,'2010-01-01','2018-09-01')
    data.Close.plot()
    plt.show()
show_stock('INFY')
[*********************100%***********************]  1 of 1 downloaded

png

show_stock('AMZN')
[*********************100%***********************]  1 of 1 downloaded

png


Score …

Category: basics

Read More
Page 14 of 17

« Prev Next »