You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article describes how to insert data from a SQL database a `pandas` dataframe using the `pyodbc` package in Python. The dataframe can be used for further data exploration. For more information, see the [pyodbc documentation](../../connect/python/pyodbc/python-sql-driver-pyodbc.md).
16
17
@@ -39,13 +40,13 @@ The sample database used in this article has been saved to a **.bak** database b
39
40
1. Follow the instructions in [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md#download-bak-files) to download the correct OLTP version of the AdventureWorks file and restore it as a database. This database will be used as a datasource.
40
41
1. Follow the directions in [Restore a database from a backup file](../../azure-data-studio/tutorial-backup-restore-sql-server.md#restore-a-database-from-a-backup-file) in Azure Data Studio, using these details:
41
42
- Import from the **AdventureWorks.bak** file - you downloaded.
1. Follow the instructions in [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md#download-bak-files) to download the correct OLTP version of the AdventureWorks file and restore it as a database. This database will be used as a datasource.
46
47
1. Follow the directions in [Restore a database to a Managed Instance](/azure/sql-database/sql-database-managed-instance-get-started-restore) in SQL Server Management Studio, using these details:
47
48
- Import from the **AdventureWorks.bak** file - you downloaded.
48
-
- Name the target database "AdventureWorks."
49
+
- Name the target database "AdventureWorks".
49
50
::: moniker-end
50
51
51
52
You can verify that the restored database exists by querying the **Person.CountryRegion** table:
@@ -71,7 +72,7 @@ To install these packages:
71
72
72
73
## Insert SQL data into dataframe
73
74
74
-
Use the following script to select data from Person.CountryRegion table and insert it into a dataframe. Edit the connection string variables 'server', 'database', 'username', and 'password' to connect to SQL Server.
75
+
Use the following script to select data from Person.CountryRegion table and insert into a dataframe. Edit the connection string variables: 'server', 'database', 'username', and 'password' to connect to SQL.
75
76
76
77
To create a new notebook:
77
78
1. In Azure Data Studio, select **File**, select **New Notebook**.
@@ -80,7 +81,6 @@ To create a new notebook:
80
81
81
82
```python
82
83
import pyodbc
83
-
import pandas
84
84
import pandas as pd
85
85
# Some other example server values are
86
86
# server = 'localhost\sqlexpress' # for a named instance
This article describes how to insert data into a SQL database from a `pandas` dataframe using the `pyodbc` package in Python. For more information, see the [pyodbc documentation](../../connect/python/pyodbc/python-sql-driver-pyodbc.md). By establishing a connection with SQL Server using Python `pandas`, data can be sent directly to a SQL table.
15
+
This article describes how to insert data into a SQL database from a `pandas` dataframe using the `pyodbc` package in Python. For more information, see the [pyodbc documentation](../../connect/python/pyodbc/python-sql-driver-pyodbc.md). By establishing a connection with SQL using Python `pandas`, data can be sent directly to a SQL table.
16
16
17
17
## Prerequisites:
18
18
@@ -40,13 +40,13 @@ The sample database used in this article has been saved to a **.bak** database b
40
40
1. Follow the instructions in [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md#download-bak-files) to download the correct OLTP version of the AdventureWorks file and restore it as a database. This database will be used as a datasource.
41
41
1. Follow the directions in [Restore a database from a backup file](../../azure-data-studio/tutorial-backup-restore-sql-server.md#restore-a-database-from-a-backup-file) in Azure Data Studio, using these details:
42
42
- Import from the **AdventureWorks.bak** file - you downloaded.
1. Follow the instructions in [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md#download-bak-files) to download the correct OLTP version of the AdventureWorks file and restore it as a database. This database will be used as a datasource.
47
47
1. Follow the directions in [Restore a database to a Managed Instance](/azure/sql-database/sql-database-managed-instance-get-started-restore) in SQL Server Management Studio, using these details:
48
48
- Import from the **AdventureWorks.bak** file - you downloaded.
49
-
- Name the target database "AdventureWorks."
49
+
- Name the target database "AdventureWorks".
50
50
::: moniker-end
51
51
52
52
You can verify that the restored database exists by querying the **HumanResources.Department** table:
1. Edit the connection string variables 'server','database','username' and 'password' to connect to SQL Server.
113
+
1. Edit the connection string variables 'server','database','username' and 'password' to connect to SQL database.
114
114
115
-
2. Edit path for CSV file.
115
+
2. Edit path for CSV file.
116
116
117
117
## Load dataframe from CSV file
118
118
119
-
Use the Python `pandas` package to create a dataframe and load the CSV file. Connect to SQL Server to load dataframe into the new SQL table, HumanResources.DepartmentTest.
120
-
Edit the connection string variables 'server', 'database', 'username', and 'password' to connect to SQL Server.
119
+
Use the Python `pandas` package to create a dataframe and load the CSV file. Connect to SQL to load dataframe into the new SQL table, HumanResources.DepartmentTest.
121
120
122
121
To create a new notebook:
123
122
1. In Azure Data Studio, select **File**, select **New Notebook**.
124
123
2. In the notebook, select kernel **Python3**, select the **+code**.
125
124
3. Paste code in notebook, select **Run All**.
126
125
127
126
```Python
128
-
import pyodbc
129
-
import pandas
127
+
import pyodbc
130
128
import pandas as pd
131
129
# insert data from csv file into dataframe.
132
130
# working directory for csv file: type "pwd" in Azure Data Studio or Linux
This article describes how to plot data using the Python package [Matplotlib](https://matplotlib.org/). A histogram displays data intervals that have consecutive, non-overlapping values.
16
+
This article describes how to plot data using the Python package [pandas'.hist()](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.hist.html). A SQL database is the source used to visualize the histogram data intervals that have consecutive, non-overlapping values.
17
17
18
18
## Prerequisites:
19
19
@@ -37,21 +37,21 @@ This article describes how to plot data using the Python package [Matplotlib](ht
37
37
38
38
The sample database used in this article has been saved to a **.bak** database backup file for you to download and use.
1. Follow the instructions in [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md#download-bak-files) to download the correct OLTP version of the AdventureWorks file and restore it as a database. This database will be used as a datasource.
40
+
1. Follow the instructions in [AdventureWorksDW sample databases](../../samples/adventureworks-install-configure.md#download-bak-files) to download the correct OLTP version of the AdventureWorks file and restore it as a database. This database will be used as a datasource.
41
41
1. Follow the directions in [Restore a database from a backup file](../../azure-data-studio/tutorial-backup-restore-sql-server.md#restore-a-database-from-a-backup-file) in Azure Data Studio, using these details:
42
-
- Import from the **AdventureWorks.bak** file - you downloaded.
43
-
- Name the target database "AdventureWorks."
42
+
- Import from the **AdventureWorksDW.bak** file - you downloaded.
1. Follow the instructions in [AdventureWorks sample databases](../../samples/adventureworks-install-configure.md#download-bak-files) to download the correct OLTP version of the AdventureWorks file and restore it as a database. This database will be used as a datasource.
46
+
1. Follow the instructions in [AdventureWorksDW sample databases](../../samples/adventureworks-install-configure.md#download-bak-files) to download the correct OLTP version of the AdventureWorks file and restore it as a database. This database will be used as a datasource.
47
47
1. Follow the directions in [Restore a database to a Managed Instance](/azure/sql-database/sql-database-managed-instance-get-started-restore) in SQL Server Management Studio, using these details:
48
-
- Import from the **AdventureWorks.bak** file - you downloaded.
49
-
- Name the target database "AdventureWorks."
48
+
- Import from the **AdventureWorksDW.bak** file - you downloaded.
49
+
- Name the target database "AdventureWorks".
50
50
::: moniker-end
51
51
52
52
You can verify that the restored database exists by querying the **Person.CountryRegion** table:
53
53
```sql
54
-
USE AdventureWorks;
54
+
USE AdventureWorksDW;
55
55
SELECT*FROMPerson.CountryRegion;
56
56
```
57
57
@@ -61,7 +61,6 @@ Install the following Python packages using [Azure Data Studio notebook with a P
61
61
62
62
* pyodbc
63
63
* pandas
64
-
* matplotlib
65
64
66
65
To install these packages:
67
66
1. In your Azure Data Studio notebook, select **Manage Packages**.
@@ -73,7 +72,7 @@ As an alternative, you can open a **Command Prompt**, change to the installation
73
72
## Plot histogram
74
73
75
74
The distributed data displayed in the histogram is based on a SQL query from AdventureWorksDW. The histogram visualizes data and the frequency of data values.
76
-
Edit the connection string variables 'server', 'database', 'username', and 'password' to connect to SQL Server.
75
+
Edit the connection string variables: 'server', 'database', 'username', and 'password' to connect to SQL database.
77
76
78
77
To create a new notebook:
79
78
1. In Azure Data Studio, select **File**, select **New Notebook**.
@@ -82,15 +81,12 @@ To create a new notebook:
82
81
83
82
```python
84
83
import pyodbc
85
-
import pandas
86
-
import pandas as pd
87
-
import matplotlib
88
-
import matplotlib.pyplot as plt
84
+
import pandas as plt
89
85
# Some other example server values are
90
86
# server = 'localhost\sqlexpress' # for a named instance
91
87
# server = 'myserver,port' # to specify an alternate port
Copy file name to clipboardExpand all lines: docs/machine-learning/python/ref-py-microsoftml.md
+6-9Lines changed: 6 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,22 @@
1
1
---
2
2
title: microsoftml Python package
3
-
description: Introduces the Microsoft machine learning algorithms and models for Python, as related to SQL Server machine learning workloads.
3
+
description: microsoftml is a Python package from Microsoft that provides high-performance machine learning algorithms. It includes functions for training and transformations, scoring, text and image analysis, and feature extraction for deriving values from existing data. The package is included in SQL Server Machine Learning Services.
**microsoftml** is a Python35-compatible module from Microsoft providing high-performance machine learning algorithms. It includes functions for training and transformations, scoring, text and image analysis, and feature extraction for deriving values from existing data.
17
-
18
-
The machine learning APIs were developed by Microsoft for internal machine learning applications and have been refined over the years to support high performance on big data, using multicore processing and fast data streaming. This package originated as a Python equivalent of an R version, [MicrosoftML](../r/ref-r-microsoftml.md), that has similar functions.
15
+
**microsoftml** is a Python package from Microsoft that provides high-performance machine learning algorithms. It includes functions for training and transformations, scoring, text and image analysis, and feature extraction for deriving values from existing data. The package is included in [SQL Server Machine Learning Services](../sql-server-machine-learning-services.md) and supports high performance on big data, using multicore processing, and fast data streaming.
19
16
20
17
## Full reference documentation
21
18
22
-
The **microsoftml**library is distributed in multiple Microsoft products, but usage is the same whether you get the library in SQL Server or another product. Because the functions are the same, [documentation for individual microsoftml functions](https://docs.microsoft.com/machine-learning-server/python-reference/microsoftml/microsoftml-package) is published to just one location under the [Python reference](https://docs.microsoft.com/machine-learning-server/python-reference/introducing-python-package-reference) for Microsoft Machine Learning Server. Should any product-specific behaviors exist, discrepancies will be noted in the function help page.
19
+
The **microsoftml**package is distributed in multiple Microsoft products, but usage is the same whether you get the package in SQL Server or another product. Because the functions are the same, [documentation for individual microsoftml functions](https://docs.microsoft.com/machine-learning-server/python-reference/microsoftml/microsoftml-package) is published to just one location under the [Python reference](https://docs.microsoft.com/machine-learning-server/python-reference/introducing-python-package-reference) for Microsoft Machine Learning Server. Should any product-specific behaviors exist, discrepancies will be noted in the function help page.
23
20
24
21
## Versions and platforms
25
22
@@ -37,7 +34,7 @@ The **microsoftml** module is based on Python 3.5 and available only when you in
37
34
Algorithms in **microsoftml** depend on [revoscalepy](ref-py-revoscalepy.md) for:
38
35
39
36
+ Data source objects. Data consumed by **microsoftml** functions are created using **revoscalepy** functions.
40
-
+ Remote computing (shifting function execution to a remote SQL Server instance). The **revoscalepy**library provides functions for creating and activating a remote compute context for SQL server.
37
+
+ Remote computing (shifting function execution to a remote SQL Server instance). The **revoscalepy**package provides functions for creating and activating a remote compute context for SQL server.
41
38
42
39
In most cases, you will load the packages together whenever you are using **microsoftml**.
0 commit comments