Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
dataframe.floordiv() function is used for integer division of the dataframe with either a constant, series or any other dataframe.
If other is a series then, the dimension of series must match with the division axis of the dataframe. If other is a data frame then, both the dataframes should have the same dimension.
dataframe/other, but with support to substitute a
fill_value for missing data in one of the inputs.
Syntax: DataFrame.floordiv(other, axis=’columns’, level=None, fill_value=None)
other : Series, DataFrame, or constant
axis : For Series input, axis to match Series index on
fill_value : Fill missing (NaN) values with this value. If both DataFrame locations are missing, the result will be missing
level : Broadcast across a level, matching Index values on the passed MultiIndex level
Returns : result : DataFrame
Example #1: Use
floordiv() function to find the integer division of a dataframe with a constant. Dataframe constains
Now apply the
floordiv() function. In our dataframe we are having
NA values. We fill all such values with 50.
Notice, all the
non-Na value in the dataframe has been filled with 50 before performing the integer division.
Example #2: Use
floordiv() function to find the integer division of a dataframe with a Series.
Each row of the dataframe is divided by the corresponding value in the series object.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.