Home > Mobile >  How to fix not working calculation in dataframe pandas python
How to fix not working calculation in dataframe pandas python

Time:03-03

hello everyone i have a problem in calculation a data frame in python. i have an equation name is TOC/Total_organic. below is the picture of my equation, code to make new colomns in my data frame, and the result code and result from running the code

def total_organic (resis_log, dens_log, base_resislog, base_denslog, LOM):
delta_log = math.log10((resis_log/base_resislog)) - 2.5*(dens_log - base_denslog)
a = 0.297 - (0.1688*LOM)
TOC = delta_log * (10**a)
return round(TOC,2)

df_2['TOC'] = total_organic(df_2['AT90'], df_2['RHOM'], 0.5, 2.7, 14.2)ode here

CodePudding user response:

The problem is that math.log10 cannot handle neither pandas dataframes nor ndarrays. You can use np.log10 instead.

import numpy as np


delta_log = np.log10((resis_log/base_resislog)) - 2.5*(dens_log - base_denslog)
  • Related