Creating a New Column in a Dataframe

How can we create a new column representing the proportion of casual riders in a dataframe?

One way to create a new column in a dataframe representing the proportion of casual riders is by dividing the number of casual riders by the total number of riders.

Creating a new column in a dataframe can be done by performing simple calculations using existing data columns. In this case, to calculate the proportion of casual riders out of all riders for each record, we need to divide the number of casual riders by the sum of casual and registered riders.

For example, in Python, if you have a dataframe called "bike" with columns named 'casual' and 'registered', you can create a new column 'prop_casual' by using the formula:

bike['prop_casual'] = bike['casual'] / (bike['casual'] + bike['registered'])

This calculation assumes that the 'casual' column represents the number of casual riders, and the 'registered' column represents the number of registered riders in the dataframe.

← A cell defined understanding the basics Exciting journey with power platform apps →