From a Python object

Before we cover all the ways we can turn a Python object into a DataFrame, we should see how to make a Series object. Remember that a Series object is essentially a column of our DataFrame object, so, once we know this, it should be easy to guess how to create a DataFrame object. Say that we wanted to create a Series of five random numbers between 0 and 1. We could use numpy to generate an array of the random numbers and create the Series from that.

To ensure that the result is reproducible, we will set the seed here. The seed gives a starting point for the generation of pseudorandom numbers. No algorithms for random number generation are truly random—they are deterministic, and therefore, by setting this starting point, ...

Get Hands-On Data Analysis with Pandas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.