Creating a pandas DataFrame
Now that we understand the data structures we will be working with, we can discuss the different ways we can create them. Before we dive into the code however, it's important to know how to get help right from Python. Should we ever find ourselves unsure of how to use something in Python, we can utilize the built-in help()
function. We simply run help()
, passing in the package, module, class, object, method, or function that we want to read the documentation on. We can, of course, look up the documentation online; however, in most cases, the docstrings (the documentation text written in the code) that are returned with help()
will be equivalent to this since they are used to generate the documentation.
Assuming we first ran import pandas as pd
, we can run help(pd)
to display information about the pandas
package; help(pd.DataFrame)
for all the methods and attributes of DataFrame
objects (note we can also pass in a DataFrame
object instead); and help...