From the course: Complete Guide to Advanced SQL Server
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Convert a series to a DataFrame - SQL Server Tutorial
From the course: Complete Guide to Advanced SQL Server
Convert a series to a DataFrame
Before you can pass data out of a Python script back to a SQL Server result set, it first needs to pass through a number of data containers. The process is going to look something like this. A collection of single scalar values are grouped together into a Python list. Then the list can be converted into a pandas series. From there, the series gets converted into a pandas DataFrame. A DataFrame is another pandas construct, like a series, but where a series can only include a single column of values, a DataFrame can contain one or more columns. Finally, the DataFrame can be assigned to the output data set variable and the contents are passed back to a SQL Server result set. Let's take a look at all of the steps in a single script. I'm starting with a couple of scalars A, B, and C that contain text strings. First, I need to put these into a list. That's done with square bracket notation, and each scalar gets separated by commas. Then the list gets converted into a series. You do that…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Return values with indexes and series6m 8s
-
(Locked)
Convert a series to a DataFrame4m 40s
-
(Locked)
Add multiple series to a DataFrame3m 12s
-
(Locked)
Include the index in a DataFrame4m 44s
-
(Locked)
Slice a DataFrame to series4m 23s
-
(Locked)
Challenge: Import and process data52s
-
(Locked)
Solution: Import and process data6m 44s
-
(Locked)
-
-
-
-