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.

Slice a DataFrame to series

Slice a DataFrame to series

When we bring data in from SQL Server through the input_data_1 parameter, it imports a DataFrame. In order to work with the values in Python, it might be useful to break that DataFrame into individual series, one series from each column in the input data set. Let's take a look at how to do this by importing some data. I've got a SELECT statement here. It says, SELECT TOP 10 CityID and CityName columns FROM the Application.Cities table. It's going to highlight all of that and execute it so you can see our starting data. And this is the data that I'm importing into my Python script. So right now we're going to have a DataFrame called InputDataSet that has two columns. To break them into individual columns, we can make reference to their column indexes. Just like with row indexing that starts with zero to represent the first row in the DataFrame, column index zero represents the first column in the DataFrame. So to split out these two columns, we want to separate column zero, the first…

Contents