Here's an example of how to iterate through a pandas dataframe, create a series of each row's information, and print each series:
main.py303 chars11 lines
In this example, we first create a dataframe with two columns ('name' and 'age') and three rows. We then iterate through the dataframe using the iterrows()
method. For each row, we create a series by passing the row's values and the dataframe's column names as parameters to the pd.Series()
function. We then print the resulting series using print(values_series)
.
The output of this code would be:
main.py146 chars10 lines
Each line corresponds to a series created for each row in the dataframe.
gistlibby LogSnag