From cf1468f286f65a01cf7219d732caf17f98589f38 Mon Sep 17 00:00:00 2001 From: ChrisAchinga Date: Mon, 14 Dec 2020 21:38:30 +0300 Subject: [PATCH 1/4] documentation for sample codes --- docs/week-1.md | 168 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/week-2.md | 148 +++++++++++++++++++++++++++++++++++++++++++ docs/week-3.md | 85 +++++++++++++++++++++++++ docs/week-4.md | 102 ++++++++++++++++++++++++++++++ docs/week-5.md | 123 ++++++++++++++++++++++++++++++++++++ 5 files changed, 626 insertions(+) create mode 100644 docs/week-1.md create mode 100644 docs/week-2.md create mode 100644 docs/week-3.md create mode 100644 docs/week-4.md create mode 100644 docs/week-5.md diff --git a/docs/week-1.md b/docs/week-1.md new file mode 100644 index 0000000..4597e94 --- /dev/null +++ b/docs/week-1.md @@ -0,0 +1,168 @@ +# Week 1: Environment Setup and Introduction + +### Downloading Python +Python comes pre-installed on Linux OS. For Windows you will have to Download. +Download Python [here](https://www.python.org/downloads/) + +### Resources +[Python For Beginnes](https://docs.microsoft.com/en-us/windows/python/beginners) + +### Text Editors + +Use a text-editor of your choice: + +Recommended are: + +[Visual Studio Code](https://code.visualstudio.com/) +[Atom](https://atom.io/) +[Sublime Text](https://www.sublimetext.com/) + +### Git and GitHub Setup. + +Note that you have to pass the challenges in git and github to proceed to the next stages. +They are essential tools in development for code sharing and collaboration. + +[Get Started Here](git-github-setup.md) + +[Raise an Issue if encountering a blocker](https://github.com/ZetechUni/python-bootcamp/issues/new) + +## Practice Code + +1. [Print](../source/week-1/print) +2. [Variables](../source/week-1/variables) +3. [Dates](../source/week-1/dates) +4. [Error Handling](../source/week-1/error-handling) +5. [Conditions](../source/week-1/conditions) + + + + + +1. ## Print + + The print function allows you to send output to the terminal + + - [print](https://docs.python.org/3/library/functions.html#print) + + Strings can be enclosed in single quotes or double quotes + + - "this is a string" + - 'this is also a string' + + The input function allows you to prompt a user for a value + + - [input](https://docs.python.org/3/library/functions.html#input) + + Parameters: + + - `prompt`: Message to display to the user + + return value: + + - string value containing value entered by user + +2. ## Variables: Numeric + + Python can store and manipulate numbers. Python has two types of numeric values: integers (whole numbers) or float (numbers with decimal places) + + - [numeric types](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex) + + When naming variables follow the PEP-8 Style Guide for Python Code + + - [PEP-8 Style Guide](https://www.python.org/dev/peps/pep-0008/#naming-conventions) + + Converting to numeric values + + - [int](https://docs.python.org/3/library/functions.html#int) + - [float](https://docs.python.org/3/library/functions.html#float) + +3. ## Variables: String + + Python can store and manipulate strings. Strings can be enclosed in single or double quotes. There are a number of string methods you can use to manipulate and work with strings + + - [strings](https://docs.python.org/3/tutorial/introduction.html#strings) + - [string methods](https://docs.python.org/3/library/stdtypes.html#string-methods) + + Converting to string values + + - [str](https://docs.python.org/3/library/functions.html#func-str) + + When naming variables follow the PEP-8 Style Guide for Python Code + + - [PEP-8 Style Guide](https://www.python.org/dev/peps/pep-0008/#naming-conventions) + +4. ## Dates + + The [datetime module](https://docs.python.org/3/library/datetime.html) contains a number of classes for manipulating dates and times. + + Date and time types: + + - `date` stores year, month, and day + - `time` stores hour, minute, and second + - `datetime` stores year, month, day, hour, minute, and second + - `timedelta` a duration of time between two dates, times, or datetimes + + When naming variables follow the PEP-8 Style Guide for Python Code + + - [PEP-8 Style Guide](https://www.python.org/dev/peps/pep-0008/#naming-conventions) + + Converting from string to datetime + + - [strptime](https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior) + +5. ## Error Handling + + Error handling in Python is managed through the use of [try/except/finally](https://docs.python.org/3.7/reference/compound_stmts.html#except) + + Python has numerous [built-in exceptions](https://docs.python.org/3.7/library/exceptions.html). When creating `except` blocks, they need to be created from most specific to most generic according to the [hierarchy](https://docs.python.org/3.7/library/exceptions.html#exception-hierarchy). + +6. ## Conditions + + Conditional execution can be completed using the [if](https://docs.python.org/3/reference/compound_stmts.html#the-if-statement) statement + + `if` syntax + + ```python + if expression: + # code to execute + else: + # code to execute + ``` + + [Comparison operators](https://docs.python.org/3/library/stdtypes.html#comparisons) + + - < less than + - < greater than + - == is equal to + - \>= greater than or equal to + - <= less than or equal to + - != not equal to + +7. ## Multiple Conditions + + Conditional execution can be completed using the [if](https://docs.python.org/3/reference/compound_stmts.html#the-if-statement) statement. Adding `elif` allows you to check multiple conditions + + `if` syntax + + ```python + if expression: + # code to execute + elif expression: + # code to execute + else: + # code to execute + ``` + + [Boolean operators](https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not) + + - **x _or_ y** - If either x OR y is true, the expression is executed + + [Comparison operators](https://docs.python.org/3/library/stdtypes.html#comparisons) + + - < less than + - < greater than + - == is equal to + - \>= greater than or equal to + - <= less than or equal to + - != not equal to + - **x _in_ [a,b,c]** Does x match the value of a, b, or c diff --git a/docs/week-2.md b/docs/week-2.md new file mode 100644 index 0000000..0e85987 --- /dev/null +++ b/docs/week-2.md @@ -0,0 +1,148 @@ +# Week 2: The Basics + +1. ## Collections (list, arrays, ranges) + + Collections are groups of items. Python supports several types of collections. Three of the most common are dictionaries, lists and arrays. + + ### Lists + + [Lists](https://docs.python.org/3/tutorial/introduction.html#lists) are a collection of items. Lists can be expanded or contracted as needed, and can contain any data type. Lists are most commonly used to store a single column collection of information, however it is possible to [nest lists](https://docs.python.org/3/tutorial/datastructures.html#nested-list-comprehensions) + + ### Arrays + + [Arrays](https://docs.python.org/3/library/array.html) are similar to lists, however are designed to store a uniform basic data type, such as integers or floating point numbers. + + ### Dictionaries + + [Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) are key/value pairs of a collection of items. Unlike a list where items can only be accessed by their index or value, dictionaries use keys to identify each item. + +2. ## Loops + + ### For loops + + [For loops](https://docs.python.org/3/reference/compound_stmts.html#the-for-statement) takes each item in an array or collection in order, and assigns it to the variable you define. + + ```python + names = ['Christopher', 'Susan'] + for name in names: + print(name) + ``` + + ### While loops + + [While loops](https://docs.python.org/3/reference/compound_stmts.html#the-while-statement) perform an operation as long as a condition is true. + + ```python + names = ['Christopher', 'Susan'] + index = 0 + while index < len(names): + name = names[index] + print(name) + index = index + 1 + ``` + +3. ## Functions + + Functions allow you to take code that is repeated and move it to a module that can be called when needed. Functions are defined with the `def` keyword and must be declared before the function is called in your code. Functions can accept parameters and return values. + + - [Functions](https://docs.python.org/3/tutorial/controlflow.html#defining-functions) + + ```python + def functionname(parameter): + # code to execute + return value + ``` + +4. ## Functions with Parameters + + Functions allow you to take code that is repeated and move it to a module that can be called when needed. Functions are defined with the `def` keyword and must be declared before the function is called in your code. Functions can accept one or more parameters and return values. + + - [Functions](https://docs.python.org/3/tutorial/controlflow.html#defining-functions) + + ```python + def function_name(parameter): + # code to execute + return value + ``` + + Parameters can be assigned a [default value](https://docs.python.org/3/tutorial/controlflow.html#default-argument-values) making them optional when the function is called. + + ```python + def function_name(parameter=default): + # code to execute + return value + ``` + + When you call a function you may specify the values for the parameters using positional or [named notation](https://docs.python.org/3/tutorial/controlflow.html#keyword-arguments) + + ```python + def function_name(parameter1, parameter2): + # code to execute + return value + + # Positional notation pass in arguments in same order as parameters are declared + result = function_name(value1,value2) + + # Named notation + result = function_name(parameter1=value1, parameter2=value2) + ``` + +5. ## Modules & Packages + + ### Modules + + [Modules](https://docs.python.org/3/tutorial/modules.html) allow you to store reusable blocks of code, such as functions, in separate files. They're referenced by using the `import` statement. + + ```python + # import module as namespace + import helpers + helpers.display('Not a warning') + + # import all into current namespace + from helpers import * + display('Not a warning') + + # import specific items into current namespace + from helpers import display + display('Not a warning') + ``` + + ### Packages + + [Distribution packages](https://packaging.python.org/glossary/#term-distribution-package) are external archive files which contain resources such as classes and functions. Most every application you create will make use of one or more packages. Imports from packages follow the same syntax as modules you've created. The [Python Package index](https://pypi.org/) contains a full list of packages you can install using [pip](https://pip.pypa.io/en/stable/). + + ### Virtual environments + + [Virtual environments](https://docs.python.org/3.7/tutorial/venv.html) allow you to install packages into an isolated folder. This allows you to better manage versions. + + ```console + + ``` + +6. ## JSON with Python + + Many APIs return data in [JSON](https://json.org/), JavaScript Object Notation. JSON is a standard format that can is readable by humans and parsed or generated by code. + + JSON is built on two structures: + + - collections of key/value pairs + - lists of values + + JSON Linters will format JSON so it easier to read by a human. The following website have JSON linters: + + - [JSONLint](https://jsonlint.com/) + - [ConvertJson.com](http://www.convertjson.com/jsonlint.htm) + - [JSON schema linter](https://www.json-schema-linter.com/) + + Python includes a [json](https://docs.python.org/2/library/json.html) module which helps you encode and decode JSON + +7. ## Decorators + + [Decorators](https://www.python.org/dev/peps/pep-0318/) are similar to attributes in that they add meaning or functionality to blocks of code in Python. They're frequently used in frameworks such as [Flask](http://flask.pocoo.org/) or [Django](https://www.djangoproject.com/). The most common interaction you'll have with decorators as a Python developer is through using them rather than creating them. + + ```python + # Example decorator + @log(True) + def sample_function(): + print('this is a sample function') + ``` diff --git a/docs/week-3.md b/docs/week-3.md new file mode 100644 index 0000000..51e54f8 --- /dev/null +++ b/docs/week-3.md @@ -0,0 +1,85 @@ +# Week 3 + +# Asynchronous operations + +Python offers several options for managing long running operations asynchronously. [asyncio](https://docs.python.org/3/library/asyncio.html) is the core library for supporting asynchronous operations, including [async](https://docs.python.org/3/reference/compound_stmts.html#async-def)/[await](https://docs.python.org/3/reference/expressions.html#await). + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +# Classes + +[Classes](https://docs.python.org/3/tutorial/classes.html) define data structures and behavior. Classes allow you to group data and functionality together. + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Object-oriented programming in Python](https://docs.microsoft.com/learn/modules/python-object-oriented-programming/?WT.mc_id=python-c9-niner) + +# Managing the file system + +Python's [pathlib](https://docs.python.org/3/library/pathlib.html) provides operations and classes to access files and directories in the file system. + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner) + +# Style Guidelines + +## Formatting + +Formatting makes code readable and easier to debug. + +## Documentation + +- [PEP 8](https://pep8.org/) is a set of coding conventions for Python code +- [Docstring](https://www.python.org/dev/peps/pep-0257/) is the standard for documenting a module, function, class or method definition + +## Linting + +Linting helps you identify formatting and convention issues in your Python code + +- [Pylint](https://www.pylint.org/) Pylint is a linter for Python to help enforce coding standards and check for errors in Python code +- [Linting Python in Visual Studio Code](https://code.visualstudio.com/docs/python/linting) will show you how to enable litners in VS Code +- [Type hints](https://docs.python.org/3/library/typing.html) allow some interactive development environments and linters to enforce types + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Set up your Python beginner development environment with Visual Studio Code](https://docs.microsoft.com/learn/languages/python-install-vscode/?WT.mc_id=python-c9-niner) + +# Inheritance + +[Inheritance](https://docs.python.org/3/tutorial/classes.html#inheritance) allows you to define a class that inherits all the methods and properties from another class. The parent or base class is the class being inherited from. The child or derived class is the class that inherits from another class. + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Object-oriented programming in Python](https://docs.microsoft.com/learn/modules/python-object-oriented-programming/?WT.mc_id=python-c9-niner) + +# Lambdas + +A [lambda](https://www.w3schools.com/python/python_lambda.asp) function is a small anonymous function. It can take any number of arguments but can only execute one expression. + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Create reusable functionality with functions in Python](https://docs.microsoft.com/learn/languages/python-functions/?WT.mc_id=python-c9-niner) + +# Mixins (multiple inheritance) + +Python allows you to inherit from multiple classes. While the technical term for this is multiple inheritance, many developers refer to the use of more than one base class adding a mixin. These are commonly used in frameworks such as [Django](https://www.djangoproject.com). + +- [Multiple Inheritance](https://docs.python.org/3/tutorial/classes.html#multiple-inheritance) +- [super](https://docs.python.org/3/library/functions.html#super) is used to give access to methods and properties of a parent class + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Object-oriented programming in Python](https://docs.microsoft.com/learn/modules/python-object-oriented-programming/?WT.mc_id=python-c9-niner) diff --git a/docs/week-4.md b/docs/week-4.md new file mode 100644 index 0000000..4cf33f4 --- /dev/null +++ b/docs/week-4.md @@ -0,0 +1,102 @@ +# Week 4: Into Data + +# Anaconda + +[Anaconda](https://www.anaconda.com/) is an open source distribution of Python and R for data science. It includes more than 1500 packages, a graphical interface called Anaconda Navigator, a command line interface called Anaconda prompt and a tool called Conda. + +## Conda + +Python code often relies on external libraries stored in packages. Conda is an open source package management system and environment management system. Conda helps you manage environments and install packages for Jupyter Notebooks. + +## Documentation + +- [Conda home page](https://docs.conda.io/) +- [Managing Conda environments](https://docs.conda.io/projects/conda/latest/user-guide/tasks/manage-environments.html) to find links and instructions for creating Conda environments, activating, and de-activating Conda environments +- [Managing packages](https://docs.conda.io/projects/conda/latest/user-guide/getting-started.html#managing-packages) to learn how to install packages in a Conda environment +- [Conda cheat sheet](https://docs.conda.io/projects/conda/latest/user-guide/cheatsheet.html) is a handy quick reference of common Conda commands + +# CSV Files and Jupyter Notebooks + +CSV files are comma separated variable file. CSV files are frequently used to store data. In order to access the data in a CSV file from a Jupyter Notebook you must upload the file. + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + +# pandas + +[pandas](https://pandas/pydata.org​) is an open source Python library contains a number of high performance data structures and tools for data analysis. + +## Documentation + +- [Series](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html) stores one dimensional arrays +- [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/frame.html) stores two dimensional arrays and can contain different datatypes + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + +# Jupyter Notebooks + +Jupyter Notebooks are an open source web application that allows you to create and share Python code. They are frequently used for data science. The code samples in this course are completed using Jupyter Notebooks which have a .ipynb file extension. + +## Documentation + +- [Jupyter](https://jupyter.org/) to install Jupyter so you can run Jupyter Notebooks locally on your computer +- [Jupyter Notebook viewer](https://nbviewer.jupyter.org/) to view Jupyter Notebooks in this GitHub repository without installing Jupyter +- [Azure Notebooks](https://notebooks.azure.com/) to create a free Azure Notebooks account to run Notebooks in the cloud +- [Create and run a notebook](https://docs.microsoft.com/azure/notebooks/tutorial-create-run-jupyter-notebook?WT.mc_id=python-c9-niner) is a tutorial that walks you through the process of using Azure Notebooks to create a complete Jupyter Notebook that demonstrates linear regression +- [How to create and clone projects](https://docs.microsoft.com/azure/notebooks/create-clone-jupyter-notebooks?WT.mc_id=python-c9-niner) to create a project +- [Manage and configure projects in Azure Notebooks](https://docs.microsoft.com/azure/notebooks/configure-manage-azure-notebooks-projects?WT.mc_id=python-c9-niner) to upload Notebooks to your project + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + +# Examining pandas DataFrame contents + +The pandas [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) is a structure for storing two-dimensional tabular data. + +## Common functions + +- [head](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.head.html) returns the first *n* rows from the DataFrame +- [tail](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.tail.html) returns the last *n* rows from the DataFrame +- [shape](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.shape.html) returns the dimensions of the DataFrame (e.g. number of rows and columns) +- [info](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.info.html) provides a summary of the DataFrame content including column names, their datatypes, and number of rows containing non-null values + +# Query a pandas DataFrame + +The pandas [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) is a structure for storing two-dimensional tabular data. + +## Common properties + +- [loc](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.loc.html) returns specific rows and columns by specifying column names +- [iloc](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.iloc.html) returns specific rows and columns by specifying column positions + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + +# Read and write CSV files from pandas DataFrames + +You can populate a DataFrame with the data in a CSV file. + +## Common functions and properties + +- [read_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html) reads a comma-separated values file into a DataFrame +- [to_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html) writes contents of a DataFrame to a comma-separated values file +- [NaN](https://pandas.pydata.org/pandas-docs/stable/user_guide/missing_data.html) is the default representation of missing values + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/docs/week-5.md b/docs/week-5.md new file mode 100644 index 0000000..c2c8fd1 --- /dev/null +++ b/docs/week-5.md @@ -0,0 +1,123 @@ +# Week 5 + +# Visualizing data with Matplotlib + +[Matplotlib](https://matplotlib.org/) gives you the ability to draw charts which can be used to visualize data. + +## Common tools and functions + +- [pyplot](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.html?highlight=pyplot#module-matplotlib.pyplot) provides the ability to draw plots similar to the MATLAB tool +- [pyplot.plot](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html#matplotlib.pyplot.plot) plots a graph +- [pyplot.show](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.show.html#matplotlib.pyplot.show) displays figures such as a graph +- [pyplot.scatter](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.scatter.html?highlight=scatter%20plot#matplotlib.pyplot.scatter) is used to draw scatter plots, a diagram that shows the relationship between two sets of data + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + + +# Handling duplicates and rows with missing values + +When preparing data for machine learning you need to remove duplicate rows and you may need to delete rows with missing values. + +## Common functions + +- [dropna](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.duplicated.html) removes rows with missing values +- [duplicated](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.duplicated.html) returns a True or False to indicate if a row is a duplicate of a previous row +- [drop_duplicates](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop_duplicates.html) returns a DataFrame with duplicate rows removed + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + +# Testing a model + +Once a model is built it can be used to predict values. You can provide new values to see where it would fall on the spectrum, and test the generated model. + +## Common classes and functions + +- [LinearRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) fits a linear model +- [LinearRegression.predict](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html?highlight=linearregression#sklearn.linear_model.LinearRegression.predict) is used to predict outcomes for new data based on the trained linear model + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + +# NumPy vs pandas + +There are numerous libraries available for use for data scientists. NumPy and pandas are two of the most common. + +Some operations may return different data types. You can use the Python function [type](https://docs.python.org/3/library/functions.html#type) to determine the type of an object. + +## NumPy + +[NumPy](https://numpy.org/) is a Python package for scientific computing that includes a array and dictionary type objects for data analysis. + +### Common object + +- [array](https://numpy.org/doc/1.18/reference/generated/numpy.array.html?highlight=array#numpy.array) creates an N-dimensional array object + +## pandas + +[pandas](https://pandas.pydata.org/) is a Python package for data analysis that includes a 1 dimensional and 2 dimensional array objects + +### Common objects + +- [Series](https://pandas.pydata.org/docs/reference/api/pandas.Series.html) stores a one dimensional array +- [DataFrame](https://pandas.pydata.org/docs/reference/frame.html) stores a two-dimensional array + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + +# Removing and splitting DataFrame columns + +When preparing data for machine learning you may need to remove specific columns from the DataFrame. + +## Common functions + +- [drop](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html) deletes specified columns from a DataFrame + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + +# Splitting test and training data with scikit-learn + +[scikit-learn](https://scikit-learn.org/) is a library of tools for predictive data analysis, which will allow you to prepare your data for machine learning and create models. + +## Common functions + +- [train_test_split](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html) splits arrays into random train and test subsets + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) + + +# Train a linear regression model with scikit-learn + +[Linear regression](https://en.wikipedia.org/wiki/Linear_regression) is a common algorithm for predicting values based on a given dataset. + +## Common classes and functions + +- [LinearRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) fits a linear model +- [LinearRegression.fit](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html?highlight=linearregression#sklearn.linear_model.LinearRegression.fit) is used to fit the linear model based on training data + +## Microsoft Learn Resources + +Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). + +- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) From c06bc5715e0af3a1a807278a305a6eba2ef37a63 Mon Sep 17 00:00:00 2001 From: ChrisAchinga Date: Mon, 14 Dec 2020 21:38:49 +0300 Subject: [PATCH 2/4] fix crowded data --- source/week-2/collections/arrays.py | 5 ++++ source/week-3/async-programming/README.md | 7 ----- source/week-3/classes/README.md | 9 ------ source/week-3/file-mgt/README.md | 7 ----- source/week-3/formatting-linting/README.md | 24 ---------------- source/week-3/inheritance/README.md | 9 ------ source/week-3/lambda/README.md | 9 ------ source/week-3/mixins/README.md | 12 -------- source/week-4/anaconda-conda-colabs/README.md | 14 ---------- source/week-4/csv-files-jupyter/README.md | 9 ------ source/week-4/intro-to-pandas/README.md | 14 ---------- source/week-4/jupyter-notebooks/README.md | 18 ------------ .../week-4/panda-dataframe-content/README.md | 10 ------- .../week-4/panda-dataframe-querry/README.md | 14 ---------- source/week-4/read-write-csv-pandas/README.md | 15 ---------- .../data-visualization-matplotlib/README.md | 16 ----------- .../README.md | 15 ---------- source/week-5/model-testing/README.md | 14 ---------- source/week-5/numpy-pandas/README.md | 28 ------------------- .../README.md | 13 --------- .../README.md | 13 --------- .../README.md | 14 ---------- 22 files changed, 5 insertions(+), 284 deletions(-) delete mode 100644 source/week-3/async-programming/README.md delete mode 100644 source/week-3/classes/README.md delete mode 100644 source/week-3/file-mgt/README.md delete mode 100644 source/week-3/formatting-linting/README.md delete mode 100644 source/week-3/inheritance/README.md delete mode 100644 source/week-3/lambda/README.md delete mode 100644 source/week-3/mixins/README.md delete mode 100644 source/week-4/anaconda-conda-colabs/README.md delete mode 100644 source/week-4/csv-files-jupyter/README.md delete mode 100644 source/week-4/intro-to-pandas/README.md delete mode 100644 source/week-4/jupyter-notebooks/README.md delete mode 100644 source/week-4/panda-dataframe-content/README.md delete mode 100644 source/week-4/panda-dataframe-querry/README.md delete mode 100644 source/week-4/read-write-csv-pandas/README.md delete mode 100644 source/week-5/data-visualization-matplotlib/README.md delete mode 100644 source/week-5/handling-duplicates-and-rows-with-missing-values/README.md delete mode 100644 source/week-5/model-testing/README.md delete mode 100644 source/week-5/numpy-pandas/README.md delete mode 100644 source/week-5/removing-and-splitting-dataFrame-columns/README.md delete mode 100644 source/week-5/splitting-test-and-training-data-with-scikit-learn/README.md delete mode 100644 source/week-5/train-a-linear-regression-model-with-scikit-learn/README.md diff --git a/source/week-2/collections/arrays.py b/source/week-2/collections/arrays.py index 3c0a225..8cd124f 100644 --- a/source/week-2/collections/arrays.py +++ b/source/week-2/collections/arrays.py @@ -1,5 +1,10 @@ +# importing array from array import array + +# decalare and assign arrays scores = array('d') + +# adding items to an array scores.append(97) scores.append(98) print(scores) \ No newline at end of file diff --git a/source/week-3/async-programming/README.md b/source/week-3/async-programming/README.md deleted file mode 100644 index f8ead89..0000000 --- a/source/week-3/async-programming/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Asynchronous operations - -Python offers several options for managing long running operations asynchronously. [asyncio](https://docs.python.org/3/library/asyncio.html) is the core library for supporting asynchronous operations, including [async](https://docs.python.org/3/reference/compound_stmts.html#async-def)/[await](https://docs.python.org/3/reference/expressions.html#await). - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). diff --git a/source/week-3/classes/README.md b/source/week-3/classes/README.md deleted file mode 100644 index 2c6b138..0000000 --- a/source/week-3/classes/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Classes - -[Classes](https://docs.python.org/3/tutorial/classes.html) define data structures and behavior. Classes allow you to group data and functionality together. - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Object-oriented programming in Python](https://docs.microsoft.com/learn/modules/python-object-oriented-programming/?WT.mc_id=python-c9-niner) diff --git a/source/week-3/file-mgt/README.md b/source/week-3/file-mgt/README.md deleted file mode 100644 index 71fa882..0000000 --- a/source/week-3/file-mgt/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Managing the file system - -Python's [pathlib](https://docs.python.org/3/library/pathlib.html) provides operations and classes to access files and directories in the file system. - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner) diff --git a/source/week-3/formatting-linting/README.md b/source/week-3/formatting-linting/README.md deleted file mode 100644 index 5bbdbb2..0000000 --- a/source/week-3/formatting-linting/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Style Guidelines - -## Formatting - -Formatting makes code readable and easier to debug. - -## Documentation - -- [PEP 8](https://pep8.org/) is a set of coding conventions for Python code -- [Docstring](https://www.python.org/dev/peps/pep-0257/) is the standard for documenting a module, function, class or method definition - -## Linting - -Linting helps you identify formatting and convention issues in your Python code - -- [Pylint](https://www.pylint.org/) Pylint is a linter for Python to help enforce coding standards and check for errors in Python code -- [Linting Python in Visual Studio Code](https://code.visualstudio.com/docs/python/linting) will show you how to enable litners in VS Code -- [Type hints](https://docs.python.org/3/library/typing.html) allow some interactive development environments and linters to enforce types - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Set up your Python beginner development environment with Visual Studio Code](https://docs.microsoft.com/learn/languages/python-install-vscode/?WT.mc_id=python-c9-niner) diff --git a/source/week-3/inheritance/README.md b/source/week-3/inheritance/README.md deleted file mode 100644 index 10e0d6a..0000000 --- a/source/week-3/inheritance/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Inheritance - -[Inheritance](https://docs.python.org/3/tutorial/classes.html#inheritance) allows you to define a class that inherits all the methods and properties from another class. The parent or base class is the class being inherited from. The child or derived class is the class that inherits from another class. - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Object-oriented programming in Python](https://docs.microsoft.com/learn/modules/python-object-oriented-programming/?WT.mc_id=python-c9-niner) diff --git a/source/week-3/lambda/README.md b/source/week-3/lambda/README.md deleted file mode 100644 index 3d50c8b..0000000 --- a/source/week-3/lambda/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Lambdas - -A [lambda](https://www.w3schools.com/python/python_lambda.asp) function is a small anonymous function. It can take any number of arguments but can only execute one expression. - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Create reusable functionality with functions in Python](https://docs.microsoft.com/learn/languages/python-functions/?WT.mc_id=python-c9-niner) diff --git a/source/week-3/mixins/README.md b/source/week-3/mixins/README.md deleted file mode 100644 index 43782c8..0000000 --- a/source/week-3/mixins/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Mixins (multiple inheritance) - -Python allows you to inherit from multiple classes. While the technical term for this is multiple inheritance, many developers refer to the use of more than one base class adding a mixin. These are commonly used in frameworks such as [Django](https://www.djangoproject.com). - -- [Multiple Inheritance](https://docs.python.org/3/tutorial/classes.html#multiple-inheritance) -- [super](https://docs.python.org/3/library/functions.html#super) is used to give access to methods and properties of a parent class - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Object-oriented programming in Python](https://docs.microsoft.com/learn/modules/python-object-oriented-programming/?WT.mc_id=python-c9-niner) diff --git a/source/week-4/anaconda-conda-colabs/README.md b/source/week-4/anaconda-conda-colabs/README.md deleted file mode 100644 index 3fc9342..0000000 --- a/source/week-4/anaconda-conda-colabs/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Anaconda - -[Anaconda](https://www.anaconda.com/) is an open source distribution of Python and R for data science. It includes more than 1500 packages, a graphical interface called Anaconda Navigator, a command line interface called Anaconda prompt and a tool called Conda. - -## Conda - -Python code often relies on external libraries stored in packages. Conda is an open source package management system and environment management system. Conda helps you manage environments and install packages for Jupyter Notebooks. - -## Documentation - -- [Conda home page](https://docs.conda.io/) -- [Managing Conda environments](https://docs.conda.io/projects/conda/latest/user-guide/tasks/manage-environments.html) to find links and instructions for creating Conda environments, activating, and de-activating Conda environments -- [Managing packages](https://docs.conda.io/projects/conda/latest/user-guide/getting-started.html#managing-packages) to learn how to install packages in a Conda environment -- [Conda cheat sheet](https://docs.conda.io/projects/conda/latest/user-guide/cheatsheet.html) is a handy quick reference of common Conda commands diff --git a/source/week-4/csv-files-jupyter/README.md b/source/week-4/csv-files-jupyter/README.md deleted file mode 100644 index 7ec63e7..0000000 --- a/source/week-4/csv-files-jupyter/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# CSV Files and Jupyter Notebooks - -CSV files are comma separated variable file. CSV files are frequently used to store data. In order to access the data in a CSV file from a Jupyter Notebook you must upload the file. - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-4/intro-to-pandas/README.md b/source/week-4/intro-to-pandas/README.md deleted file mode 100644 index cee037f..0000000 --- a/source/week-4/intro-to-pandas/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# pandas - -[pandas](https://pandas/pydata.org​) is an open source Python library contains a number of high performance data structures and tools for data analysis. - -## Documentation - -- [Series](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html) stores one dimensional arrays -- [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/frame.html) stores two dimensional arrays and can contain different datatypes - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-4/jupyter-notebooks/README.md b/source/week-4/jupyter-notebooks/README.md deleted file mode 100644 index 363489c..0000000 --- a/source/week-4/jupyter-notebooks/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Jupyter Notebooks - -Jupyter Notebooks are an open source web application that allows you to create and share Python code. They are frequently used for data science. The code samples in this course are completed using Jupyter Notebooks which have a .ipynb file extension. - -## Documentation - -- [Jupyter](https://jupyter.org/) to install Jupyter so you can run Jupyter Notebooks locally on your computer -- [Jupyter Notebook viewer](https://nbviewer.jupyter.org/) to view Jupyter Notebooks in this GitHub repository without installing Jupyter -- [Azure Notebooks](https://notebooks.azure.com/) to create a free Azure Notebooks account to run Notebooks in the cloud -- [Create and run a notebook](https://docs.microsoft.com/azure/notebooks/tutorial-create-run-jupyter-notebook?WT.mc_id=python-c9-niner) is a tutorial that walks you through the process of using Azure Notebooks to create a complete Jupyter Notebook that demonstrates linear regression -- [How to create and clone projects](https://docs.microsoft.com/azure/notebooks/create-clone-jupyter-notebooks?WT.mc_id=python-c9-niner) to create a project -- [Manage and configure projects in Azure Notebooks](https://docs.microsoft.com/azure/notebooks/configure-manage-azure-notebooks-projects?WT.mc_id=python-c9-niner) to upload Notebooks to your project - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-4/panda-dataframe-content/README.md b/source/week-4/panda-dataframe-content/README.md deleted file mode 100644 index aa35bb3..0000000 --- a/source/week-4/panda-dataframe-content/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Examining pandas DataFrame contents - -The pandas [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) is a structure for storing two-dimensional tabular data. - -## Common functions - -- [head](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.head.html) returns the first *n* rows from the DataFrame -- [tail](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.tail.html) returns the last *n* rows from the DataFrame -- [shape](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.shape.html) returns the dimensions of the DataFrame (e.g. number of rows and columns) -- [info](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.info.html) provides a summary of the DataFrame content including column names, their datatypes, and number of rows containing non-null values diff --git a/source/week-4/panda-dataframe-querry/README.md b/source/week-4/panda-dataframe-querry/README.md deleted file mode 100644 index ea22708..0000000 --- a/source/week-4/panda-dataframe-querry/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Query a pandas DataFrame - -The pandas [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) is a structure for storing two-dimensional tabular data. - -## Common properties - -- [loc](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.loc.html) returns specific rows and columns by specifying column names -- [iloc](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.iloc.html) returns specific rows and columns by specifying column positions - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-4/read-write-csv-pandas/README.md b/source/week-4/read-write-csv-pandas/README.md deleted file mode 100644 index 84fd680..0000000 --- a/source/week-4/read-write-csv-pandas/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Read and write CSV files from pandas DataFrames - -You can populate a DataFrame with the data in a CSV file. - -## Common functions and properties - -- [read_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html) reads a comma-separated values file into a DataFrame -- [to_csv](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html) writes contents of a DataFrame to a comma-separated values file -- [NaN](https://pandas.pydata.org/pandas-docs/stable/user_guide/missing_data.html) is the default representation of missing values - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-5/data-visualization-matplotlib/README.md b/source/week-5/data-visualization-matplotlib/README.md deleted file mode 100644 index add4b17..0000000 --- a/source/week-5/data-visualization-matplotlib/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Visualizing data with Matplotlib - -[Matplotlib](https://matplotlib.org/) gives you the ability to draw charts which can be used to visualize data. - -## Common tools and functions - -- [pyplot](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.html?highlight=pyplot#module-matplotlib.pyplot) provides the ability to draw plots similar to the MATLAB tool -- [pyplot.plot](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html#matplotlib.pyplot.plot) plots a graph -- [pyplot.show](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.show.html#matplotlib.pyplot.show) displays figures such as a graph -- [pyplot.scatter](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.scatter.html?highlight=scatter%20plot#matplotlib.pyplot.scatter) is used to draw scatter plots, a diagram that shows the relationship between two sets of data - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-5/handling-duplicates-and-rows-with-missing-values/README.md b/source/week-5/handling-duplicates-and-rows-with-missing-values/README.md deleted file mode 100644 index 04e453a..0000000 --- a/source/week-5/handling-duplicates-and-rows-with-missing-values/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Handling duplicates and rows with missing values - -When preparing data for machine learning you need to remove duplicate rows and you may need to delete rows with missing values. - -## Common functions - -- [dropna](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.duplicated.html) removes rows with missing values -- [duplicated](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.duplicated.html) returns a True or False to indicate if a row is a duplicate of a previous row -- [drop_duplicates](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop_duplicates.html) returns a DataFrame with duplicate rows removed - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-5/model-testing/README.md b/source/week-5/model-testing/README.md deleted file mode 100644 index 9fd8956..0000000 --- a/source/week-5/model-testing/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Testing a model - -Once a model is built it can be used to predict values. You can provide new values to see where it would fall on the spectrum, and test the generated model. - -## Common classes and functions - -- [LinearRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) fits a linear model -- [LinearRegression.predict](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html?highlight=linearregression#sklearn.linear_model.LinearRegression.predict) is used to predict outcomes for new data based on the trained linear model - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-5/numpy-pandas/README.md b/source/week-5/numpy-pandas/README.md deleted file mode 100644 index 2182364..0000000 --- a/source/week-5/numpy-pandas/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# NumPy vs pandas - -There are numerous libraries available for use for data scientists. NumPy and pandas are two of the most common. - -Some operations may return different data types. You can use the Python function [type](https://docs.python.org/3/library/functions.html#type) to determine the type of an object. - -## NumPy - -[NumPy](https://numpy.org/) is a Python package for scientific computing that includes a array and dictionary type objects for data analysis. - -### Common object - -- [array](https://numpy.org/doc/1.18/reference/generated/numpy.array.html?highlight=array#numpy.array) creates an N-dimensional array object - -## pandas - -[pandas](https://pandas.pydata.org/) is a Python package for data analysis that includes a 1 dimensional and 2 dimensional array objects - -### Common objects - -- [Series](https://pandas.pydata.org/docs/reference/api/pandas.Series.html) stores a one dimensional array -- [DataFrame](https://pandas.pydata.org/docs/reference/frame.html) stores a two-dimensional array - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-5/removing-and-splitting-dataFrame-columns/README.md b/source/week-5/removing-and-splitting-dataFrame-columns/README.md deleted file mode 100644 index 539d8f0..0000000 --- a/source/week-5/removing-and-splitting-dataFrame-columns/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Removing and splitting DataFrame columns - -When preparing data for machine learning you may need to remove specific columns from the DataFrame. - -## Common functions - -- [drop](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html) deletes specified columns from a DataFrame - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-5/splitting-test-and-training-data-with-scikit-learn/README.md b/source/week-5/splitting-test-and-training-data-with-scikit-learn/README.md deleted file mode 100644 index fdc5aa7..0000000 --- a/source/week-5/splitting-test-and-training-data-with-scikit-learn/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Splitting test and training data with scikit-learn - -[scikit-learn](https://scikit-learn.org/) is a library of tools for predictive data analysis, which will allow you to prepare your data for machine learning and create models. - -## Common functions - -- [train_test_split](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html) splits arrays into random train and test subsets - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) diff --git a/source/week-5/train-a-linear-regression-model-with-scikit-learn/README.md b/source/week-5/train-a-linear-regression-model-with-scikit-learn/README.md deleted file mode 100644 index 62f0f31..0000000 --- a/source/week-5/train-a-linear-regression-model-with-scikit-learn/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Train a linear regression model with scikit-learn - -[Linear regression](https://en.wikipedia.org/wiki/Linear_regression) is a common algorithm for predicting values based on a given dataset. - -## Common classes and functions - -- [LinearRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) fits a linear model -- [LinearRegression.fit](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html?highlight=linearregression#sklearn.linear_model.LinearRegression.fit) is used to fit the linear model based on training data - -## Microsoft Learn Resources - -Explore related tutorials on [Microsoft Learn](https://learn.microsoft.com/?WT.mc_id=python-c9-niner). - -- [Intro to machine learning with Python and Azure Notebooks](https://docs.microsoft.com/learn/paths/intro-to-ml-with-python/?WT.mc_id=python-c9-niner) From 3997eb77a4129f54032263d12b4296731e16329e Mon Sep 17 00:00:00 2001 From: ChrisAchinga Date: Mon, 14 Dec 2020 21:51:33 +0300 Subject: [PATCH 3/4] week 2 review --- README.md | 330 +----------------- docs/week-2.md | 2 +- source/week-2/loops/for.py | 2 +- source/week-2/loops/number.py | 2 +- source/week-2/loops/while.py | 2 +- .../__pycache__/helpers.cpython-38.pyc | Bin 0 -> 335 bytes .../modules-and-packages/color_import_demo.py | 2 +- 7 files changed, 12 insertions(+), 328 deletions(-) create mode 100644 source/week-2/modules-and-packages/__pycache__/helpers.cpython-38.pyc diff --git a/README.md b/README.md index 6783d1a..bab6748 100644 --- a/README.md +++ b/README.md @@ -9,43 +9,13 @@ ## 5 Weeks Of Python (Roadmap) -## Week 1: Environment Setup and Introduction - -### Downloading Python -Python comes pre-installed on Linux OS. For Windows you will have to Download. -Download Python [here](https://www.python.org/downloads/) - -### Resources -[Python For Beginnes](https://docs.microsoft.com/en-us/windows/python/beginners) - -### Text Editors - -Use a text-editor of your choice: - -Recommended are: - -[Visual Studio Code](https://code.visualstudio.com/) -[Atom](https://atom.io/) -[Sublime Text](https://www.sublimetext.com/) - -### Git and GitHub Setup. - -Note that you have to pass the challenges in git and github to proceed to the next stages. -They are essential tools in development for code sharing and collaboration. - -[Get Started Here](git-github-setup.md) - -[Raise an Issue if encountering a blocker](https://github.com/ZetechUni/python-bootcamp/issues/new) - -## Practice Code - -1. [Print](source/week-1/print) -2. [Variables](source/week-1/variables) -3. [Dates](source/week-1/dates) -4. [Error Handling](source/week-1/error-handling) -5. [Conditions](source/week-1/conditions) - +[Week 1](docs/week-1.md) +[Week 2](docs/week-2.md) +[Week 3](docs/week-3.md) +[Week 4](docs/week-3.md) +[Week 5](docs/week-5.md) + ## Setting Up Your Developer Environment @@ -127,289 +97,3 @@ As the Bootcamp is open to anyone, we encourage members of our community, Facebo [Read More On Contributions](CONTRIBUTING.md) -
- -# WEEK 1: Introduction - -1. ## Print - - The print function allows you to send output to the terminal - - - [print](https://docs.python.org/3/library/functions.html#print) - - Strings can be enclosed in single quotes or double quotes - - - "this is a string" - - 'this is also a string' - - The input function allows you to prompt a user for a value - - - [input](https://docs.python.org/3/library/functions.html#input) - - Parameters: - - - `prompt`: Message to display to the user - - return value: - - - string value containing value entered by user - -2. ## Variables: Numeric - - Python can store and manipulate numbers. Python has two types of numeric values: integers (whole numbers) or float (numbers with decimal places) - - - [numeric types](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex) - - When naming variables follow the PEP-8 Style Guide for Python Code - - - [PEP-8 Style Guide](https://www.python.org/dev/peps/pep-0008/#naming-conventions) - - Converting to numeric values - - - [int](https://docs.python.org/3/library/functions.html#int) - - [float](https://docs.python.org/3/library/functions.html#float) - -3. ## Variables: String - - Python can store and manipulate strings. Strings can be enclosed in single or double quotes. There are a number of string methods you can use to manipulate and work with strings - - - [strings](https://docs.python.org/3/tutorial/introduction.html#strings) - - [string methods](https://docs.python.org/3/library/stdtypes.html#string-methods) - - Converting to string values - - - [str](https://docs.python.org/3/library/functions.html#func-str) - - When naming variables follow the PEP-8 Style Guide for Python Code - - - [PEP-8 Style Guide](https://www.python.org/dev/peps/pep-0008/#naming-conventions) - -4. ## Dates - - The [datetime module](https://docs.python.org/3/library/datetime.html) contains a number of classes for manipulating dates and times. - - Date and time types: - - - `date` stores year, month, and day - - `time` stores hour, minute, and second - - `datetime` stores year, month, day, hour, minute, and second - - `timedelta` a duration of time between two dates, times, or datetimes - - When naming variables follow the PEP-8 Style Guide for Python Code - - - [PEP-8 Style Guide](https://www.python.org/dev/peps/pep-0008/#naming-conventions) - - Converting from string to datetime - - - [strptime](https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior) - -5. ## Error Handling - - Error handling in Python is managed through the use of [try/except/finally](https://docs.python.org/3.7/reference/compound_stmts.html#except) - - Python has numerous [built-in exceptions](https://docs.python.org/3.7/library/exceptions.html). When creating `except` blocks, they need to be created from most specific to most generic according to the [hierarchy](https://docs.python.org/3.7/library/exceptions.html#exception-hierarchy). - -6. ## Conditions - - Conditional execution can be completed using the [if](https://docs.python.org/3/reference/compound_stmts.html#the-if-statement) statement - - `if` syntax - - ```python - if expression: - # code to execute - else: - # code to execute - ``` - - [Comparison operators](https://docs.python.org/3/library/stdtypes.html#comparisons) - - - < less than - - < greater than - - == is equal to - - \>= greater than or equal to - - <= less than or equal to - - != not equal to - -7. ## Multiple Conditions - - Conditional execution can be completed using the [if](https://docs.python.org/3/reference/compound_stmts.html#the-if-statement) statement. Adding `elif` allows you to check multiple conditions - - `if` syntax - - ```python - if expression: - # code to execute - elif expression: - # code to execute - else: - # code to execute - ``` - - [Boolean operators](https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not) - - - **x _or_ y** - If either x OR y is true, the expression is executed - - [Comparison operators](https://docs.python.org/3/library/stdtypes.html#comparisons) - - - < less than - - < greater than - - == is equal to - - \>= greater than or equal to - - <= less than or equal to - - != not equal to - - **x _in_ [a,b,c]** Does x match the value of a, b, or c - -
- -
-# Week 2: The Basics - -1. ## Collections (list, arrays, ranges) - - Collections are groups of items. Python supports several types of collections. Three of the most common are dictionaries, lists and arrays. - - ### Lists - - [Lists](https://docs.python.org/3/tutorial/introduction.html#lists) are a collection of items. Lists can be expanded or contracted as needed, and can contain any data type. Lists are most commonly used to store a single column collection of information, however it is possible to [nest lists](https://docs.python.org/3/tutorial/datastructures.html#nested-list-comprehensions) - - ### Arrays - - [Arrays](https://docs.python.org/3/library/array.html) are similar to lists, however are designed to store a uniform basic data type, such as integers or floating point numbers. - - ### Dictionaries - - [Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) are key/value pairs of a collection of items. Unlike a list where items can only be accessed by their index or value, dictionaries use keys to identify each item. - -2. ## Loops - - ### For loops - - [For loops](https://docs.python.org/3/reference/compound_stmts.html#the-for-statement) takes each item in an array or collection in order, and assigns it to the variable you define. - - ```python - names = ['Christopher', 'Susan'] - for name in names: - print(name) - ``` - - ### While loops - - [While loops](https://docs.python.org/3/reference/compound_stmts.html#the-while-statement) perform an operation as long as a condition is true. - - ```python - names = ['Christopher', 'Susan'] - index = 0 - while index < len(names): - name = names[index] - print(name) - index = index + 1 - ``` - -3. ## Functions - - Functions allow you to take code that is repeated and move it to a module that can be called when needed. Functions are defined with the `def` keyword and must be declared before the function is called in your code. Functions can accept parameters and return values. - - - [Functions](https://docs.python.org/3/tutorial/controlflow.html#defining-functions) - - ```python - def functionname(parameter): - # code to execute - return value - ``` - -4. ## Functions with Parameters - - Functions allow you to take code that is repeated and move it to a module that can be called when needed. Functions are defined with the `def` keyword and must be declared before the function is called in your code. Functions can accept one or more parameters and return values. - - - [Functions](https://docs.python.org/3/tutorial/controlflow.html#defining-functions) - - ```python - def function_name(parameter): - # code to execute - return value - ``` - - Parameters can be assigned a [default value](https://docs.python.org/3/tutorial/controlflow.html#default-argument-values) making them optional when the function is called. - - ```python - def function_name(parameter=default): - # code to execute - return value - ``` - - When you call a function you may specify the values for the parameters using positional or [named notation](https://docs.python.org/3/tutorial/controlflow.html#keyword-arguments) - - ```python - def function_name(parameter1, parameter2): - # code to execute - return value - - # Positional notation pass in arguments in same order as parameters are declared - result = function_name(value1,value2) - - # Named notation - result = function_name(parameter1=value1, parameter2=value2) - ``` - -5. ## Modules & Packages - - ### Modules - - [Modules](https://docs.python.org/3/tutorial/modules.html) allow you to store reusable blocks of code, such as functions, in separate files. They're referenced by using the `import` statement. - - ```python - # import module as namespace - import helpers - helpers.display('Not a warning') - - # import all into current namespace - from helpers import * - display('Not a warning') - - # import specific items into current namespace - from helpers import display - display('Not a warning') - ``` - - ### Packages - - [Distribution packages](https://packaging.python.org/glossary/#term-distribution-package) are external archive files which contain resources such as classes and functions. Most every application you create will make use of one or more packages. Imports from packages follow the same syntax as modules you've created. The [Python Package index](https://pypi.org/) contains a full list of packages you can install using [pip](https://pip.pypa.io/en/stable/). - - ### Virtual environments - - [Virtual environments](https://docs.python.org/3.7/tutorial/venv.html) allow you to install packages into an isolated folder. This allows you to better manage versions. - - ```console - - ``` - -6. ## JSON with Python - - Many APIs return data in [JSON](https://json.org/), JavaScript Object Notation. JSON is a standard format that can is readable by humans and parsed or generated by code. - - JSON is built on two structures: - - - collections of key/value pairs - - lists of values - - JSON Linters will format JSON so it easier to read by a human. The following website have JSON linters: - - - [JSONLint](https://jsonlint.com/) - - [ConvertJson.com](http://www.convertjson.com/jsonlint.htm) - - [JSON schema linter](https://www.json-schema-linter.com/) - - Python includes a [json](https://docs.python.org/2/library/json.html) module which helps you encode and decode JSON - -7. ## Decorators - - [Decorators](https://www.python.org/dev/peps/pep-0318/) are similar to attributes in that they add meaning or functionality to blocks of code in Python. They're frequently used in frameworks such as [Flask](http://flask.pocoo.org/) or [Django](https://www.djangoproject.com/). The most common interaction you'll have with decorators as a Python developer is through using them rather than creating them. - - ```python - # Example decorator - @log(True) - def sample_function(): - print('this is a sample function') - ``` - -
diff --git a/docs/week-2.md b/docs/week-2.md index 0e85987..ab19e96 100644 --- a/docs/week-2.md +++ b/docs/week-2.md @@ -23,7 +23,7 @@ [For loops](https://docs.python.org/3/reference/compound_stmts.html#the-for-statement) takes each item in an array or collection in order, and assigns it to the variable you define. ```python - names = ['Christopher', 'Susan'] + names = ['John Doe', 'Jane Doe'] for name in names: print(name) ``` diff --git a/source/week-2/loops/for.py b/source/week-2/loops/for.py index 90bf46a..2c04168 100644 --- a/source/week-2/loops/for.py +++ b/source/week-2/loops/for.py @@ -1,2 +1,2 @@ -for name in ['Christopher', 'Susan']: +for name in ['John Doe', 'Jane Doe']: print(name) diff --git a/source/week-2/loops/number.py b/source/week-2/loops/number.py index b9d4caa..bf6f563 100644 --- a/source/week-2/loops/number.py +++ b/source/week-2/loops/number.py @@ -2,5 +2,5 @@ # First parameter is the starter # Second indicates the number of numbers to create # range(0, 2) creates [0, 1] -for index in range(0, 2): +for index in range(0, 1000): print(index) diff --git a/source/week-2/loops/while.py b/source/week-2/loops/while.py index f2ab2ab..c08c3cc 100644 --- a/source/week-2/loops/while.py +++ b/source/week-2/loops/while.py @@ -1,4 +1,4 @@ -names = ['Christopher', 'Susan'] +names = ['John Doe', 'Jane Doe'] index = 0 while index < len(names): print(names[index]) diff --git a/source/week-2/modules-and-packages/__pycache__/helpers.cpython-38.pyc b/source/week-2/modules-and-packages/__pycache__/helpers.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d2ad62edff5bd61f040481e26d2619725ca2e0a6 GIT binary patch literal 335 zcmYjLu};G<5WPziS}MxS+A%}0#EcLUQpYZUkh)ZEY&BMs*z%=RLEYeI_!{;s4159` z6K6uDKIy%8=kuN3<76@h#wUF&4f|JUjxpfomPzL>;=UUX121r%%$?re05{DRznTrf$-x8&;Y~uJvMUXu0cuyn_!R zejY?&D=qTE8xl%C3)eP Date: Mon, 14 Dec 2020 21:59:52 +0300 Subject: [PATCH 4/4] created file --- docs/git-github-setup.md | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 docs/git-github-setup.md diff --git a/docs/git-github-setup.md b/docs/git-github-setup.md new file mode 100644 index 0000000..390dd2c --- /dev/null +++ b/docs/git-github-setup.md @@ -0,0 +1,68 @@ +# GitHub Setup + +> GitHub offers the distributed version control and source code management and collaboration. + +**Below are resources to getting started with GitHub.** + +> You are supposed to complete the practical activities after going through the resources for you to qualify to the next stage. + +| Be sure to have the basic knowledge of using github: | +|--| +| Creating a repository | +| Forking a repository | +| Updating a Forked Repository | +| Creating a Branch | +| Creating a Pull Request | +| Creating a Issues | + +## GitHub Basics + +1. [Official Guides by GitHub](https://guides.github.com/) +2. [Creating a Repository](https://guides.github.com/activities/hello-world/) +3. [Getting Started With GitHub](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github) + +## Git Setup + +What is git? +Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. + +Resources: + +[git-scm website](https://git-scm.com/) +[Downloading git](https://git-scm.com/download) +[Configuring git with GitHub](https://chrisdev.hashnode.dev/git-and-github-installation-and-configuration) + +## Practical Activities + +### Activity 1: + +- Create a GitHub Repository using your account. +- Clone the repository to your local environment, using either git or gh-cli. +- Create a new file: + + >Use the following naming convection: {github-username}.txt +- Add the following details to the created file: + + >your github username and your github email + +- Update your repository using `git`. + + i.e: + + ```shell + git add . + git commit -m "your commit message" + git push + ``` + + N.B Use a better commit message. + +### Activity 2 + +- Head over to https://github.com/ZetechUni/github-collaborations +- Fork the repository +- Create a new branch using the following naming convection: ({github-username}-patch) +- Add your details in the README.md under the "Contributors" title. +- Update your repository. +- Create a pull request. +- After creating a pull request, create an issue: \ No newline at end of file