How do I get all of the numbers in the pandas dataframe to enter and exit this function?

Viewed 33

I have an excel file of ratios which I then would like to make a pandas data frame for. After this I would like to apply this equation to all the numbers, however it works for some but not all. When I test these error numbers in a separate file they do give me a number. I think the error has to do with the pandas df and Numpy.log10 which seems to be common. I would like to keep it in pandas as I manipulate it further to export in a way I can copy and paste it into prism.

### Imports ###
import numpy as np
import pandas as pd
import math
from datetime import datetime
### Constants for sigmoidal curve ###
betaTop = 3.559
betaBot = 0.3792
pka = 7.482
n = 0.7567
filename = "file.xlsx"

### Load excel File ###
f = pd.read_excel(filename, header=None)

### Sigmoid pH Equation ###
def sigmoid(x):
        return pka + (n ** -1)*np.log10(((x - betaBot)/(betaTop - betaBot))/(1 - ((x - betaBot)/(betaTop - betaBot))))

### Apply Function to all Columns ###
f = f.apply(sigmoid, axis =0) # acounts for any nan values as well as 
puts into the formula

This is the output I keep recieving:

RuntimeWarning: invalid value encountered in log10 result = 
getattr(ufunc, method)(*inputs, **kwargs)
0 Answers
Related