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.
Add multiple series to a DataFrame - SQL Server Tutorial
From the course: Complete Guide to Advanced SQL Server
Add multiple series to a DataFrame
The main difference between a series and a DataFrame is that a DataFrame can hold multiple columns of data. To combine multiple series into a single DataFrame, you're going to need to use the DataFrame constructor. Let's start by creating several variables to hold some text. The first three, A, B, and C, will be set to the values of apple, banana, and cherry, and the second set of three, X, Y, and Z, will be the colors red, yellow, and red again. Now, first, I'm going to collect these scalars and group them into two different series. The first one I'll call fruit. We're going to group them into a pandas series and we'll import the list for A, B, and C. The second series I'll call color and that'll import the list X, Y, and Z. Now, I want to add both of these as two different columns in a single DataFrame. We can do this by constructing the DataFrame from something called a dictionary. A Python dictionary separates groups of keys and values with a colon and is contained within curly…
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)
-
-
-
-