I am using Pandas to make a DataFrame. However some parts of the DataFrame contain a string. how can I ignore these strings in the sum when summing along the rows of the data frame?
df["sum"] = df.sum(axis=1)
Use the numeric_only
flag:
df.sum(axis=1, numeric_only=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With