<jupyter_start><jupyter_text>SDE & DS Modularity, Documentation, & Automated Testing<jupyter_code># import the numpy package
import numpy as np

# create an array class object
arr = np.array([8, 6, 7, 5, 3, 0, 9])

# use the sort method
arr.sort()

# print the sorted array
print(arr)
words = ['DataCamp',
 'Introduction',
 'to',
 'H',
 'O',
 'AutoML',
 'In',
 'this',
 'tutorial',
 'you',
 'will',
 'learn',
 'about',
 'H',
 'O',
 'and',
 'have',
 'a',
 'glimpse',
 'of',
 'its',
 'auto',
 'DataCamp',
 'Stocks',
 'Significance',
 'Testing',
 'p',
 'Hacking',
 'Learn',
 'how',
 'to',
 'manipulate',
 'time',
 'series',
 'data',
 'with',
 'pandas',
 'and',
 'co',
 'RT',
 '@cbismuth',
 'Linear',
 'regression',
 'example',
 'with',
 'most',
 'significant',
 'features',
 'detection',
 '#DataCamp',
 '#DataScience',
 '#Python',
 '#sklearn',
 'Linear',
 'regression',
 'example',
 'with',
 'most',
 'significant',
 'features',
 'detection',
 '#DataCamp',
 '#DataScience',
 '#Python',
 '#sklearn',
 'Basic',
 'linear',
 'regression',
 'example',
 '#DataCamp',
 '#DataScience',
 '#Python',
 '#sklearn',
 'RT',
 '@David',
 'Makinde',
 'I',
 'just',
 'completed',
 'Introduction',
 'to',
 'Python',
 'for',
 'Data',
 'Science',
 '#Datacamp',
 '#DataScience',
 '#Python',
 'DataCamp',
 'Enter',
 'the',
 '#DataFramedChallenge',
 'for',
 'a',
 'chance',
 'to',
 'be',
 'on',
 'an',
 'upcoming',
 'podcast',
 'segment',
 'DataCamp',
 'has',
 'a',
 'pod',
 'DataCamp',
 'Introduction',
 'to',
 'Python',
 'Metaclasses',
 'In',
 'this',
 'tutorial',
 'you',
 'll',
 'learn',
 'about',
 'metaclasses',
 'in',
 'Python',
 'by',
 'De',
 'I',
 'just',
 'completed',
 'Introduction',
 'to',
 'Python',
 'for',
 'Data',
 'Science',
 '#Datacamp',
 '#DataScience',
 '#Python',
 'RT',
 '@cbismuth',
 'My',
 'pretty',
 'first',
 'classifier',
 '#DataCamp',
 '#Python',
 '#sklearn',
 'My',
 'pretty',
 'first',
 'classifier',
 '#DataCamp',
 '#Python',
 '#sklearn',
 'RT',
 '@ascentt',
 'The',
 'different',
 '#DataScience',
 'roles',
 'on',
 'the',
 'job',
 'market',
 '#SoftwareTesting',
 '#DataEngineer',
 '#DataScientist',
 'The',
 'different',
 '#DataScience',
 'roles',
 'on',
 'the',
 'job',
 'market',
 '#SoftwareTesting',
 '#DataEngineer',
 'Consegu',
 'el',
 'contacto',
 'de',
 'una',
 'de',
 'las',
 'encargadas',
 'de',
 'la',
 'divisi',
 'n',
 'inform',
 'tica',
 'de',
 'la',
 'OPP',
 'gracias',
 'a',
 'la',
 'gente',
 'del',
 'Weapons',
 'of',
 'Math',
 'Destruction',
 '#datacamp',
 '#podcast',
 'DataCamp',
 'Shareable',
 'Data',
 'Science',
 'with',
 'Kyso',
 'In',
 'this',
 'tutorial',
 'you',
 'll',
 'learn',
 'how',
 'to',
 'create',
 'publishable',
 'and',
 'reprod',
 'Studying',
 'has',
 'to',
 'be',
 'done',
 'every',
 'day',
 'prepare',
 'yourself',
 'for',
 'the',
 'next',
 'opportunity',
 'A',
 'leader',
 'must',
 'show',
 'how',
 'its',
 'done',
 '@DataCamp',
 '#learningR',
 '#programming',
 '#datacamp',
 'Trilha',
 'incr',
 'vel',
 'de',
 'Programa',
 'o',
 'em',
 'Python',
 'do',
 'projeto',
 'DataCamp',
 'conclu',
 'da',
 'com',
 'sucesso',
 '#DataCamp',
 '#DataScience',
 'Depois',
 'de',
 'um',
 'longo',
 'dia',
 'de',
 'trabalho',
 'hora',
 'de',
 'investir',
 'no',
 'futuro',
 '#OQueVamosAprenderHoje',
 '#datascience',
 '#dsa',
 'RT',
 '@charlyingsparks',
 'This',
 'is',
 'so',
 'spot',
 'on',
 '@DataCamp',
 '@hugobowne',
 '#DataFramedchallenge',
 '@hmason',
 '#empathy',
 '#datascience',
 '#datacamp',
 'RT',
 '@gastronomy',
 'DataCamp',
 'Naive',
 'Bayes',
 'Classification',
 'using',
 'Scikit',
 'learn',
 'Learn',
 'how',
 'to',
 'build',
 'and',
 'evaluate',
 'a',
 'Naive',
 'Bayes',
 'Classifier',
 'using',
 'DataCamp',
 'Naive',
 'Bayes',
 'Classification',
 'using',
 'Scikit',
 'learn',
 'Learn',
 'how',
 'to',
 'build',
 'and',
 'evaluate',
 'a',
 'Naive',
 'Bayes',
 'Classifi',
 'This',
 'is',
 'so',
 'spot',
 'on',
 '@DataCamp',
 '@hugobowne',
 '#DataFramedchallenge',
 '@hmason',
 '#empathy',
 '#datascience',
 '#datacamp',
 'If',
 'you',
 'want',
 'to',
 'learn',
 'Data',
 'Science',
 'start',
 'with',
 'one',
 'of',
 'these',
 'programming',
 'classes',
 'by',
 '@venturidb',
 'Learning',
 'about',
 '#Shiny',
 'in',
 '#Datacamp',
 'with',
 '@minebocek',
 'RT',
 '@aaysbt',
 'Day',
 'I',
 'jsut',
 'completed',
 'the',
 'statistical',
 'thingking',
 'course',
 '@DataCamp',
 'There',
 'was',
 'lot',
 'of',
 'thinks',
 'to',
 'learn',
 'my',
 'brain',
 'is',
 'killing',
 'me',
 '@BernieMat',
 '@epi',
 'twit',
 '@DataCamp',
 '@RStudioJoe',
 '@zabormetrics',
 '@malco',
 'barrett',
 '@epi',
 'twit',
 '@DataCamp',
 '@RStudioJoe',
 '@zabormetrics',
 'This',
 'is',
 'perfect',
 'You',
 'may',
 'have',
 'just',
 'saved',
 'me',
 'months',
 'of',
 'stress',
 'in',
 'one',
 'tweet',
 '@BernieMat',
 '@epi',
 'twit',
 '@DataCamp',
 'DataCamp',
 'has',
 'a',
 'course',
 'on',
 'survival',
 'analysis',
 '@malco',
 'barrett',
 '@epi',
 'twit',
 '@DataCamp',
 'And',
 'thanks',
 'for',
 'the',
 'refs',
 'extremely',
 'helpful',
 '@malco',
 'barrett',
 '@epi',
 'twit',
 '@DataCamp',
 'Things',
 'such',
 'as',
 'setting',
 'up',
 'data',
 'for',
 'survival',
 'analysis',
 'I',
 'use',
 'stset',
 'religiously',
 'in',
 'Stata',
 'I',
 'can',
 't',
 'continue',
 'the',
 'class',
 'Text',
 'Mining',
 'Bag',
 'of',
 'Words',
 '@DataCamp',
 '@BernieMat',
 '@epi',
 'twit',
 'In',
 'general',
 'I',
 'recommend',
 '@DataCamp',
 'and',
 'R',
 'for',
 'Data',
 'Science',
 'RT',
 '@khalid',
 'amer',
 'Day',
 'of',
 'DaysOfCode',
 'I',
 'have',
 'finished',
 'the',
 'chapter',
 'Customizing',
 'plots',
 'from',
 'Introduction',
 'to',
 'Data',
 'Visualization',
 'with',
 'P',
 'RT',
 '@DataCamp',
 'New',
 'Tutorial',
 'Introduction',
 'to',
 'Python',
 'Metaclasses',
 'In',
 'this',
 'tutorial',
 'learn',
 'what',
 '#metaclasses',
 'are',
 'how',
 'to',
 'implement',
 'them',
 'in',
 '#Py',
 'I',
 'just',
 'completed',
 'the',
 'course',
 'Joining',
 'Data',
 'in',
 'PostgreSQL',
 'Business',
 'people',
 'do',
 'not',
 'need',
 'to',
 'apologize',
 'for',
 'wanting',
 'to',
 'know',
 'what',
 'the',
 'customer',
 'wants',
 '@andrewgelman',
 'with',
 'Big',
 'data',
 'tends',
 'to',
 'be',
 'messy',
 'data',
 'Instead',
 'of',
 'a',
 'random',
 'sample',
 'you',
 'often',
 'get',
 'a',
 'convenient',
 'sample',
 '@andrewgelman',
 '@DataCamp',
 'do',
 'you',
 'have',
 'a',
 'curriculum',
 'suggestion',
 'to',
 'mimic',
 'the',
 'Quantitative',
 'Analyst',
 'with',
 'R',
 'track',
 'but',
 'focused',
 'on',
 'RT',
 '@mustafanafees',
 '@DataCamp',
 's',
 'Data',
 'Science',
 'And',
 '#MachineLearning',
 'Programs',
 'A',
 'Review',
 '@drjekyll',
 '@DataCamp',
 '@dataquestio',
 '@kaggle',
 'ooh',
 'cool',
 'I',
 'don',
 't',
 'know',
 'them',
 'might',
 'give',
 'something',
 'a',
 'try',
 '@iC',
 'dE',
 '@dataquestio',
 '@DataCamp',
 'both',
 'offer',
 'courses',
 'that',
 'are',
 'really',
 'good',
 'I',
 'm',
 'doing',
 'the',
 'python',
 'pipeline',
 'and',
 'it',
 's',
 'free',
 '@Dame',
 'Of',
 'Spades',
 '@DataCamp',
 '@dataquestio',
 'both',
 'offer',
 'free',
 'courses',
 'that',
 'are',
 'really',
 'good',
 '@kaggle',
 'is',
 'another',
 'good',
 'one',
 'wi',
 'Thanks',
 '@NickCarchedi',
 'and',
 '@DataCamp',
 'for',
 'Intro',
 'to',
 'SQL',
 'for',
 'Data',
 'Science',
 'Great',
 'course',
 'RT',
 '@DataCamp',
 'Analyzing',
 'Police',
 'Activity',
 'with',
 'pandas',
 'In',
 'this',
 'course',
 'you',
 'll',
 'practice',
 'cleaning',
 'messy',
 'data',
 'create',
 'visualizations',
 'This',
 'cour',
 'Day',
 'I',
 'jsut',
 'completed',
 'the',
 'statistical',
 'thingking',
 'course',
 '@DataCamp',
 'There',
 'was',
 'lot',
 'of',
 'thinks',
 'to',
 'learn',
 'my',
 'brain',
 'is',
 'RT',
 '@gelliottmorris',
 'Want',
 'to',
 'learn',
 'how',
 'to',
 'analyze',
 'political',
 'data',
 'Trying',
 'to',
 'figure',
 'out',
 '#rstats',
 'and',
 'want',
 'a',
 'familiar',
 'dataset',
 'I',
 've',
 'got',
 'somethi',
 'RT',
 '@drjekyll',
 'DaysOfCode',
 'R',
 'D',
 'I',
 'just',
 'completed',
 'the',
 'course',
 'Intro',
 'to',
 'Python',
 'for',
 'Data',
 'Science',
 'I',
 'just',
 'completed',
 'the',
 'course',
 'Intro',
 'to',
 'Python',
 'for',
 'Data',
 'Science',
 '@DataCamp',
 's',
 'Data',
 'Science',
 'And',
 '#MachineLearning',
 'Programs',
 'A',
 'Review',
 'I',
 'just',
 'completed',
 'the',
 'course',
 'Importing',
 'Data',
 'in',
 'Python',
 'Part',
 '@nnstats',
 '@DataCamp',
 'Another',
 'question',
 'any',
 'special',
 'reasons',
 'for',
 'using',
 'RStata',
 'Are',
 'there',
 'things',
 'Stata',
 'can',
 'do',
 'that',
 'R',
 'can',
 't',
 'Tq',
 '#Python',
 'vs',
 'R',
 'battle',
 'for',
 'supremacy',
 'in',
 '#DataScience',
 '#Infographic',
 'by',
 '@DataCamp',
 '#BigData',
 '@DataCamp',
 'It',
 'would',
 'be',
 'awesome',
 'if',
 'we',
 'could',
 'bookmark',
 'courses',
 'we',
 're',
 'interested',
 'in',
 'It',
 'd',
 'be',
 'even',
 'more',
 'awesome',
 'if',
 'we',
 'could',
 'create',
 'playlists',
 'RT',
 '@DataCamp',
 'Modeling',
 'with',
 'Data',
 'in',
 'the',
 'Tidyverse',
 'In',
 'this',
 'course',
 'you',
 'will',
 'learn',
 'to',
 'model',
 'with',
 'data',
 'Models',
 'attempt',
 'to',
 'capture',
 'the',
 'relatio',
 '@JamesMarsh',
 '@DataCamp',
 'Thanks',
 '@ShipSystem',
 '@DataCamp',
 'I',
 'did',
 'think',
 'the',
 'interface',
 'worked',
 'well',
 'and',
 'directions',
 'were',
 'clear',
 'most',
 'of',
 'the',
 'time',
 '@JamesMarsh',
 '@DataCamp',
 'any',
 'feedback',
 'I',
 'm',
 'entering',
 '#dataframedchallenge',
 'and',
 'you',
 'll',
 'see',
 'me',
 'coming',
 'Can',
 't',
 'wait',
 'to',
 'listen',
 'to',
 'some',
 'great',
 'podcasts',
 '@DataCamp',
 '@hugobowne',
 'I',
 'just',
 'completed',
 'the',
 'course',
 'Introduction',
 'to',
 'R',
 'Thoroughly',
 'enjoyed',
 'the',
 'Introduction',
 'to',
 'the',
 'Tidyverse',
 'course',
 '@DataCamp',
 'by',
 '@drob',
 'Great',
 'instructor',
 'RT',
 '@jenineharris',
 'I',
 'am',
 'so',
 'excited',
 'to',
 'officially',
 'be',
 'a',
 '@DataCamp',
 'instructor',
 'Thank',
 'you',
 'to',
 'the',
 'fantastic',
 '@old',
 'man',
 'chester',
 'and',
 '@venturidb',
 'for',
 'w',
 '@jenineharris',
 '@DataCamp',
 '@old',
 'man',
 'chester',
 '@venturidb',
 'WHAT',
 'Congrats',
 'Dr',
 'HaRRis',
 'Thoroughly',
 'enjoyed',
 'the',
 'Career',
 'Track',
 'Data',
 'Scientist',
 'with',
 'R',
 '@DataCamp',
 'course',
 'great',
 'instructors',
 'getting',
 'the',
 'most',
 'ou',
 'Want',
 'to',
 'learn',
 'how',
 'to',
 'analyze',
 'political',
 'data',
 'Trying',
 'to',
 'figure',
 'out',
 '#rstats',
 'and',
 'want',
 'a',
 'familiar',
 'dataset',
 'I',
 've',
 'got',
 'som',
 'I',
 'just',
 'completed',
 'the',
 'course']

len(words)
# load the Counter function into our environment
from collections import Counter

# View the documentation for Counter.most_common
help(Counter.most_common)

# use Counter to find the top 5 most common words
top_5_words = Counter(words).most_common(5)

# display the top 5 most common words
print(top_5_words)<jupyter_output>Help on method most_common in module collections:

most_common(self, n=None) unbound collections.Counter method
    List the n most common elements and their counts from the most
    common to the least.  If n is None, then list all element counts.
    
    >>> Counter('abcdeabcdabcaba').most_common(3)
    [('a', 5), ('b', 4), ('c', 3)]

[('to', 37), ('@DataCamp', 33), ('the', 27), ('I', 21), ('RT', 15)]<jupyter_text>Writing a Module<jupyter_code># Import needed functionality
from collections import Counter

def plot_counter(counter, n_most_common=5):
  # Subset the n_most_common items from the input counter
  top_items = counter.most_common(n_most_common)
  # Plot `top_items`
  plot_counter_most_common(top_items)<jupyter_output><empty_output><jupyter_text>Object Oriented Programming  DRY* Don't* Repeat* Yourself<jupyter_code># Define a SocialMedia class that is a child of the `Document class`
class SocialMedia(Document):
    def __init__(self, text):
        Document.__init__(self, text)

# Define a SocialMedia class that is a child of the `Document class`
class SocialMedia(Document):
    def __init__(self, text):
        Document.__init__(self, text)
        self.hashtag_counts = self._count_hashtags()
        self.mention_counts = self._count_mentions()
        
    def _count_hashtags(self):
        # Filter attribute so only words starting with '#' remain
        return filter_word_counts(self.word_counts, first_char='#')      
    
    def _count_mentions(self):
        # Filter attribute so only words starting with '@' remain
        return filter_word_counts(self.word_counts, first_char='@')<jupyter_output><empty_output><jupyter_text>Mutileve Inheritance<jupyter_code># Define a Tweet class that inherits from SocialMedia
class Tweets(SocialMedia):
    def __init__(self, text):
        # Call parent's __init__ with super()
        super().__init__(self, text)
        # Define retweets attribute with non-public method
        self.retweets = self._process_retweets()

    def _process_retweets(self):
        # Filter tweet text to only include retweets
        retweet_text = filter_lines(self.text, first_chars='RT')
        # Return retweet_text as a SocialMedia object
        return SocialMedia(retweet_text)<jupyter_output><empty_output><jupyter_text>Getting Ready for OOP<jupyter_code>numbers = [1, 2, 3, 4, 5, 6]

# Create function that returns the average of an integer list
def average_numbers(num_list): 
    avg = sum(num_list)/float(len(num_list)) # divide by length of list
    return avg

# Take the average of a list: my_avg
my_avg = average_numbers(numbers)

# Print out my_avg
print(my_avg)
# Create a list that contains two lists: matrix
matrix = [[1,2,3,4], [5,6,7,8]]

# Print the matrix list
print(matrix)
# Create empty class: DataShell
# with or w/out parenthasis "()"
class DataShell:
  
    # Pass statement
    pass

# Instantiate DataShell: my_data_shell
my_data_shell = DataShell()

# Print my_data_shell
print(my_data_shell)
# Python 2.* style class w/ (object)
# Create empty class: DataShell
class DataShell(object):
  
    # Pass statement
    pass

# Instantiate DataShell: my_data_shell
my_data_shell = DataShell()

# Print my_data_shell
print(my_data_shell)
# Take a look at python keywords
# self is not a keyword in python
import keyword
print(keyword.kwlist)
# Create class: DataShell
class DataShell:
  
	# Initialize class with self argument
    def __init__(self):
      
        # Pass statement
        pass

# Instantiate DataShell: my_data_shell
my_data_shell = DataShell()

# Print my_data_shell
print(my_data_shell)
# Create class: DataShell
class DataShell:
  
	# Initialize class with self and integerInput arguments
    def __init__(self, integerInput):
      
		# Set data as instance variable, and assign the value of integerInput
        self.data = integerInput

# Declare variable x with value of 10
x = 10

# Instantiate DataShell passing x as argument: my_data_shell
my_data_shell = DataShell(x)

# Print my_data_shell
print(my_data_shell.data)
# Create class: DataShell
class DataShell:
  
	# Initialize class with self, identifier and data arguments
    def __init__(self, identifier, data):
      
		# Set identifier and data as instance variables, assigning value of input arguments
        self.identifier = identifier
        self.data = data

# Declare variable x with value of 100, and y with list of integers from 1 to 5
x = 100
y = [1, 2, 3, 4, 5]

# Instantiate DataShell passing x and y as arguments: my_data_shell
my_data_shell = DataShell(x, y)

# Print my_data_shell.identifier
print(my_data_shell.identifier)

# Print my_data_shell.data
print(my_data_shell.data)
# Create class: DataShell
class DataShell:
  
    # Declare a class variable family, and assign value of "DataShell"
    family = 'DataShell'
    
    # Initialize class with self, identifier arguments
    def __init__(self, identifier):
      
        # Set identifier as instance variable of input argument
        self.identifier = identifier

# Declare variable x with value of 100
x = 100

# Instantiate DataShell passing x as argument: my_data_shell
my_data_shell = DataShell(x)

# Print my_data_shell class variable family
print(my_data_shell.family)
# Create class: DataShell
class DataShell:
  
    # Declare a class variable family, and assign value of "DataShell"
    family = 'DataShell'
    
    # Initialize class with self, identifier arguments
    def __init__(self, identifier):
      
        # Set identifier as instance variables, assigning value of input arguments
        self.identifier = identifier

# Declare variable x with value of 100
x = 100

# Instantiate DataShell passing x and y as arguments: my_data_shell
my_data_shell = DataShell(x)

# Print my_data_shell class variable family
print(my_data_shell.family)

# Override the my_data_shell.family value with "NotDataShell"
my_data_shell.family = 'NotDataShell'

# Print my_data_shell class variable family once again
print(my_data_shell.family)
# Create class: DataShell
class DataShell:
  
	# Initialize class with self argument
    def __init__(self):
        pass
      
	# Define class method which takes self argument: print_static
    def print_static(self):
        # Print string
        print("You just executed a class method!")
        
# Instantiate DataShell taking no arguments: my_data_shell
my_data_shell = DataShell()

# Call the print_static method of your newly created object
my_data_shell.print_static()
# Create class: DataShell
class DataShell:
  
	# Initialize class with self and dataList as arguments
    def __init__(self, dataList):
      	# Set data as instance variable, and assign it the value of dataList
        self.data = dataList
        
	# Define class method which takes self argument: show
    def show(self):
        # Print the instance variable data
        print(self.data)

# Declare variable with list of integers from 1 to 10: integer_list   
integer_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        
# Instantiate DataShell taking integer_list as argument: my_data_shell
my_data_shell = DataShell(integer_list)

# Call the show method of your newly created object
my_data_shell.show()
# Create class: DataShell
class DataShell:
  
	# Initialize class with self and dataList as arguments
    def __init__(self, dataList):
      	# Set data as instance variable, and assign it the value of dataList
        self.data = dataList
        
	# Define method that prints data: show
    def show(self):
        print(self.data)
        
    # Define method that prints average of data: avg 
    def avg(self):
        # Declare avg and assign it the average of data
        avg = sum(self.data)/float(len(self.data))
        # Print avg
        print(avg)
        
# Instantiate DataShell taking integer_list as argument: my_data_shell
my_data_shell = DataShell(integer_list)

# Call the show and avg methods of your newly created object
my_data_shell.show()
my_data_shell.avg()
# Create class: DataShell
class DataShell:
  
	# Initialize class with self and dataList as arguments
    def __init__(self, dataList):
      	# Set data as instance variable, and assign it the value of dataList
        self.data = dataList
        
	# Define method that returns data: show
    def show(self):
        return self.data
        
    # Define method that prints average of data: avg 
    def avg(self):
        # Declare avg and assign it the average of data
        avg = sum(self.data)/float(len(self.data))
        # Return avg
        return avg
        
# Instantiate DataShell taking integer_list as argument: my_data_shell
my_data_shell = DataShell(integer_list)

# Print output of your object's show method
print(my_data_shell.show())

# Print output of your object's avg method
print(my_data_shell.avg())
us_life_expectancy = 'https://assets.datacamp.com/production/repositories/2097/datasets/5dd3a8250688a4f08306206fa1d40f63b66bc8a9/us_life_expectancy.csv'
# Load numpy as np and pandas as pd
import pandas as pd
import numpy as np

# Create class: DataShell
class DataShell:
  
    # Initialize class with self and inputFile
    def __init__(self, inputFile):
        self.file = inputFile
        
    # Define generate_csv method, with self argument
    def generate_csv(self):
        self.data_as_csv = pd.read_csv(self.file)
        return self.data_as_csv

# Instantiate DataShell with us_life_expectancy as input argument
data_shell = DataShell(us_life_expectancy)

# Call data_shell's generate_csv method, assign it to df
df = data_shell.generate_csv()

# Print df
print(df.head())
# Import numpy as np, pandas as pd
import numpy as np
import pandas as pd

# Create class: DataShell
class DataShell:
  
    # Define initialization method
    def __init__(self, filepath):
        # Set filepath as instance variable  
        self.filepath = filepath
        # Set data_as_csv as instance variable
        self.data_as_csv = pd.read_csv(filepath)

# Instantiate DataShell as us_data_shell
us_data_shell = DataShell(us_life_expectancy)

# Print your object's data_as_csv attribute
print(us_data_shell.data_as_csv)
# Create class DataShell
class DataShell:
  
    # Define initialization method
    def __init__(self, filepath):
        self.filepath = filepath
        self.data_as_csv = pd.read_csv(filepath)
    
    # Define method rename_column, with arguments self, column_name, and new_column_name
    def rename_column(self, column_name, new_column_name):
        self.data_as_csv.columns = self.data_as_csv.columns.str.replace(column_name, new_column_name)

# Instantiate DataShell as us_data_shell with argument us_life_expectancy
us_data_shell = DataShell(us_life_expectancy)

# Print the datatype of your object's data_as_csv attribute
print(us_data_shell.data_as_csv.dtypes)

# Rename your objects column 'code' to 'country_code'
us_data_shell.rename_column('code', 'country_code')

# Again, print the datatype of your object's data_as_csv attribute
print(us_data_shell.data_as_csv.dtypes)
# Create class DataShell
class DataShell:

    # Define initialization method
    def __init__(self, filepath):
        self.filepath = filepath
        self.data_as_csv = pd.read_csv(filepath)

    # Define method rename_column, with arguments self, column_name, and new_column_name
    def rename_column(self, column_name, new_column_name):
        self.data_as_csv.columns = self.data_as_csv.columns.str.replace(column_name, new_column_name)
        
    # Define get_stats method, with argument self
    def get_stats(self):
        # Return a description data_as_csv
        return self.data_as_csv.describe()
    
# Instantiate DataShell as us_data_shell
us_data_shell = DataShell(us_life_expectancy)

# Print the output of your objects get_stats method
print(us_data_shell.get_stats())<jupyter_output>year  life_expectancy
count   117.000000       117.000000
mean   1956.752137        66.556684
std      34.398252         9.551079
min    1880.000000        39.410000
25%    1928.000000        58.500000
50%    1957.000000        69.599998
75%    1986.000000        74.772003
max    2015.000000        79.244003<jupyter_text>Inheritance  Inheritance： Expand your class method without overwriting<jupyter_code># Create a class Animal
class Animal:
	def __init__(self, name):
		self.name = name

# Create a class Mammal, which inherits from Animal
class Mammal(Animal):
	def __init__(self, name, animal_type):
		self.animal_type = animal_type

# Create a class Reptile, which also inherits from Animal
class Reptile(Animal):
	def __init__(self, name, animal_type):
		self.animal_type = animal_type

# Instantiate a mammal with name 'Daisy' and animal_type 'dog': daisy
daisy = Mammal('Daisy', 'dog')

# Instantiate a reptile with name 'Stella' and animal_type 'alligator': stella
stella = Reptile('Stella', 'alligator')

# Print both objects
print(daisy)
print(stella)
# Create a class Vertebrate
class Vertebrate:
    spinal_cord = True
    def __init__(self, name):
        self.name = name

# Create a class Mammal, which inherits from Vertebrate
class Mammal(Vertebrate):
    def __init__(self, name, animal_type):
        self.animal_type = animal_type
        self.temperature_regulation = True

# Create a class Reptile, which also inherits from Vertebrate
class Reptile(Vertebrate):
    def __init__(self, name, animal_type):
        self.animal_type = animal_type
        self.temperature_regulation = False

# Instantiate a mammal with name 'Daisy' and animal_type 'dog': daisy
daisy = Mammal('Daisy', 'dog')

# Instantiate a reptile with name 'Stella' and animal_type 'alligator': stella
stella = Reptile('Stella', 'alligator')

# Print stella's attributes spinal_cord and temperature_regulation
print("Stella Spinal cord: " + str(stella.spinal_cord))
print("Stella temperature regularization: " + str(stella.temperature_regulation))

# Print daisy's attributes spinal_cord and temperature_regulation
print("Daisy Spinal cord: " + str(daisy.spinal_cord))
print("Daisy temperature regularization: " + str(daisy.temperature_regulation))
# Load numpy as np and pandas as pd
import numpy as np
import pandas as pd

# Create class: DataShell
class DataShell:
    def __init__(self, inputFile):
        self.file = inputFile

# Instantiate DataShell as my_data_shell
my_data_shell = DataShell(us_life_expectancy)

# Print my_data_shell
print(my_data_shell)
# Load numpy as np and pandas as pd
import numpy as np
import pandas as pd

# Create class: DataShell
class DataShell:
    def __init__(self, inputFile):
        self.file = inputFile

# Create class CsvDataShell, which inherits from DataShell
class CsvDataShell(DataShell):
    # Initialization method with arguments self, inputFile
    def __init__(self, inputFile):
        # Instance variable data
        self.data = pd.read_csv(inputFile)

# Instantiate CsvDataShell as us_data_shell, passing us_life_expectancy as argument
us_data_shell = CsvDataShell(us_life_expectancy)

# Print us_data_shell.data
print(us_data_shell.data)<jupyter_output>country code  year  life_expectancy
0    United States  USA  1880        39.410000
1    United States  USA  1890        45.209999
2    United States  USA  1901        49.299999
3    United States  USA  1902        50.500000
4    United States  USA  1903        50.599998
5    United States  USA  1904        49.599998
6    United States  USA  1905        50.299999
7    United States  USA  1906        50.099998
8    United States  USA  1907        50.200001
9    United States  USA  1908        51.900002
10   United States  USA  1909        52.799999
11   United States  USA  1910        51.799999
12   United States  USA  1911        53.400002
13   United States  USA  1912        54.099998
14   United States  USA  1913        53.500000
15   United States  USA  1914        54.599998
16   United States  USA  1915        55.099998
17   United States  USA  1916        54.200001
18   United States  USA  1917        54.000000
19   United States  USA  1918        47.200001
20   United S[...]<jupyter_text>Composition<jupyter_code># Define abstract class DataShell
class DataShell:
    # Class variable family
    family = 'DataShell'
    # Initialization method with arguments, and instance variables
    def __init__(self, name, filepath): 
        self.name = name
        self.filepath = filepath

# Define class CsvDataShell      
class CsvDataShell(DataShell):
    # Initialization method with arguments self, name, filepath
    def __init__(self, name, filepath):
        # Instance variable data
        self.data = pd.read_csv(filepath)
        # Instance variable stats
        self.stats = self.data.describe()

# Instantiate CsvDataShell as us_data_shell
us_data_shell = CsvDataShell("US", us_life_expectancy)

# Print us_data_shell.stats
print(us_data_shell.stats)
france_life_expectancy = 'https://assets.datacamp.com/production/repositories/2097/datasets/e3620bc33a17d7ce5cf0ae87e723171284c81df3/france_life_expectancy.csv'
# Define abstract class DataShell
class DataShell:
    family = 'DataShell'
    def __init__(self, name, filepath): 
        self.name = name
        self.filepath = filepath

# Define class CsvDataShell
class CsvDataShell(DataShell):
    def __init__(self, name, filepath):
        self.data = pd.read_csv(filepath)
        self.stats = self.data.describe()

# Define class TsvDataShell
class TsvDataShell(DataShell):
    # Initialization method with arguments self, name, filepath
    def __init__(self, name, filepath):
        # Instance variable data
        self.data = pd.read_table(filepath)
        # Instance variable stats
        self.stats = self.data.describe()

# Instantiate CsvDataShell as us_data_shell, print us_data_shell.stats
us_data_shell = CsvDataShell("US", us_life_expectancy)
print(us_data_shell.stats)

# Instantiate TsvDataShell as france_data_shell, print france_data_shell.stats
france_data_shell = TsvDataShell('France', france_life_expectancy)
print(france_data_shell.stats)
mtcars = 'https://assets.datacamp.com/production/repositories/2097/datasets/054e2f80f31a05a79db90f58068523b5a92d1ba1/mtcars.csv'<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15467317006148457, 'fraction_numerical': 0.020437605193556144, 'mean_word_length': 3.89640094180962, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 29, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '411864', 'license': 'MIT', 'n_tokens_mistral': 10859, 'n_tokens_neox': 10173, 'n_words': 2818, 'path': '20190323_Python_SDE.ipynb', 'repo_name': 'Nifsupreme/Applied-Deep-Learning-with-TensorFlow', 'size': '29113'}