Course Hero Logo
Question
Answered

Using the above functions, move (copy) the code for the three...

Image transcription text

def calculate_common (dataset, column) : items = dataset [column ] . unique( ) out count = {} for item in items: item counter = 0 for ind in dataset. index: if dataset . loc[ind, column] == item: item counter += 1 out_count [item] = item counter def sort_dict (dictionary, reverse_it = True) : sorted_dictionary = sorted (dictionary . items(), key = lambda x: x[1], reverse = reverse_it) return sorted_dictionary sorted dict = sort_dict (out_count) return sorted dict[0]

... Show more

Image transcription text

def calculate_unique (data, variable) : num_unique=len (data [variable ] . unique ( ) ) num total=len (data) return num unique, num total, (num unique/num total)

... Show more

Image transcription text

def split dataset (dataset, n_split=3): shuffled = dataset . sample (frac = 1, replace = False) result = np.array_split (shuffled, n split) return result

... Show more


  1. Using the above functions, move (copy) the code for the three functions (calculate_unique(), split_dataset() and calculate_common()) into a file named my_experiment.py. This file should be stored in the same directory as this notebook.
  2. Add numpy docstrings to each function.
  3. Add lines to import numpy as np and pandas as pd at the top of your module.
  4. Save your changes to my_experiment.py

Answer & Explanation
Verified Solved by verified expert
<p>rem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae</p> Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet

Unlock full access to Course Hero

Explore over 16 million step-by-step answers from our library

Subscribe to view answer

m risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec a