try it . mode () method:
In [88]: df Out[88]: abc 0 2 3 3 1 1 1 2 2 7 7 8 In [89]: df.mode(axis=1) Out[89]: 0 0 3 1 1 2 7
From the docs:
Gets the mode of each item along the selected axis. Adds a line for each mode to the label fills the blanks with nan.
Note that there may be several values โโreturned for the selected one (when more than one position shares the maximum frequency), which is the reason the data frame is returned. If you want to dispute the missing values โโwith the mode in the df data frame, you can simply do this: df.fillna (df.mode (). Iloc [0])
source share