I get this csv from my program and i want to get the "thickness"/difference of each of my Depth values.
So for example 3998 - 4002 = -4
is there a way to use this csv or is it useless because i couldn't find anything that would solve my problem.
df = pd.read_csv ('/PermeabilityData.csv',sep=";")
display(df)
a = df['Depth [ft]'].loc[data.index[0]]
Depth [ft] Permeability [mD]
0 3998-4002 180
1 4002-4004 150
2 4004-4006 200
3 4006-4008 140
4 4008-4010 160
CodePudding user response:
A possible solution:
df['Depth [ft]'].map(eval)
Output:
0 -4
1 -2
2 -2
3 -2
4 -2
Name: Depth [ft], dtype: int64
CodePudding user response:
This could also be done:
pd.eval(df.iloc[:,0])
[-4, -2, -2, -2, -2]
CodePudding user response:
In lieu of using the eval, here is one way to do it
df['Depth[ft]'].str.split('-',expand=True).astype(int).apply(lambda x: x[0]-x[1], axis=1)
0 -4
1 -2
2 -2
3 -2
4 -2
dtype: int32