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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access