From the course: SQL Server Machine Learning Services: Python
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Add multiple series to a data frame
From the course: SQL Server Machine Learning Services: Python
Add multiple series to a data frame
- [Narrator] The main difference between a series and a data frame is that a data frame can hold multiple columns of data. To combine multiple series in to a single data frame, you're going to need to use the data frame constructor. Let's start by creating several variables to hold some text. (typing) The first three, A, B, and C, will be set to the value 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 in to two different series. The first one I'll call "fruit." (typing) We're going to group them in to a Pandas Series and we'll import the list for A, B, and C. (typing) The second set of series I'll call "color." And that'll import the list X, Y, and Z. Now we want to add both of these as two different columns in a single data frame. We can do this by constructing the data frame from something called a dictionary. A Python dictionary separates groups of…
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 data frame4m 40s
-
(Locked)
Add multiple series to a data frame3m 12s
-
(Locked)
Include the index in a data frame4m 44s
-
(Locked)
Slice a data frame to series4m 23s
-
(Locked)
Challenge: Import and process data52s
-
(Locked)
Solution: Import and process data6m 44s
-
(Locked)
-
-
-