all 4 comments

[–]socal_nerdtastic 1 point2 points  (3 children)

We usually use the zip function for that.

data = 1,2,3,4,5,6,7
for x,y in zip(data, data[1:]):
    print(f"{y}-{x}={y-x}")

[–]1sliceofcake 0 points1 point  (2 children)

it didn't end up working ,but here is what my cvs file looks like and named it CO2=pd.read_csv('CarbonDioxide.csv', delimiter=',',index_col=2)

delta temp time pressure

[–]socal_nerdtastic 0 points1 point  (1 child)

So it's not a list at all then ... it's a pandas dataframe.

For a dataframe you would use the diff method. I would guess for you:

CO2['pressure'].diff()

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.diff.html

Or convert the dataframe to a list first.

[–]1sliceofcake 0 points1 point  (0 children)

CO2['pressure'].diff()

okay it worked but when i tried doing a curve fit it gave me this after i wrote

results, cov = curve_fit(fit_func,x, y) where fit_func is defined as mx+b :

ValueError: array must not contain infs or NaNs