十、Popular Python Packages
1、What are APIs
Application Programming Interface
2、Search for Business
3、Hiding API Keys
so now when we push our codes to Github repository, our config file will not be there
十一、使用Dyjango构建Web应用程序
1、Your First Django Project
then the virtual environment for this project is activated(虽然好像没用
2、Creating an App
续上节ctrl-c后
3、Views
Index represents the main page of an app
在movies/view.py:
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def index(request):
return HttpResponse("Hello World")
movies下创建一个urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
]
在vidly下的urls.py中修改加上,变为:
urlpatterns = [
path('admin/', admin.site.urls),
path('movies/', include('movies.urls'))
]
再次
这时你会惊奇的发现:
4、Models
在movies/models.py:
from django.db import models
class Genre(models.Model):
name = models.CharField(max_length=255)
class Movie(models.Model):
title = models.CharField(max_length=255)
release_year = models.IntegerField()
number_in_stock = models.IntegerField()
daily_rate = models.FloatField()
genre = models.ForeignKey(Genre, on_delete=models.CASCADE())
5、Migrations
看到项目目录下的db.sqlite3
在SQLite下打开数据库,打开项目中的这个sqlite3
Everytime we create new model classes or modify existing ones, we tell django to compare our model classes with our database, and based on that it would create a migration
A migration is essentially a python file, that includes some code let me run that it will synchronize our database with our model classes
no changes are detected because by default Django is not aware of our model classes
So the first step is to register movies app with Django, let me show you how to do that
vidly/settings.py
修改部分成为:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'movies.apps.MoviesConfig'
]
十二、使用Python进行机器学习
1、Machine Learning in Action
2、Libraries and Tools
LIBRARIES: Numpy, Pandas, MatPlotLib, Scikit-Learn
Numpy which provides a multi-dimensional array
Pandas which of the data analysis library that provide a concept called dataframe,
A dataframe is a two dimentsional data structure similar to an Excel spreadsheet, so we have rows and columns
MatPlotLib is a two dimensional plotting library for creating graphs on plots
Scikit-Learn provides all these common algorithms
1、安装Anaconda
2、安装jupyter
pip install notebook
3、启动
进入Desktop文件夹下,
新建后重命名为HelloWorld
3、Importing a Data Set
kaggle
中搜索video game sales
可以看到要下载的是vgsales.csv,其中有11列
点击下载,然后将下载好的csv文件放在和刚才ipynb文件同一目录下
4、Jupyter Shortcuts
选中是绿色「编辑模式」,再按一下esc,会变成蓝色「命令模式」
按a在选中的上面添加一行,按b在选中的下面添加一行,按两次d删除一行
df.
然后按tab可以出现自动提示,对象中所有的属性和方法
cursor在方法名上然后按shift和tab可以看到提示:
cmd + / 注释
5、A Real Problem
下载music.csv
6、Preparing the Data