0

I have various dataframes, each has a different depth range.

For a more complex computation (this is a fragment of a question posted here: Curve fitting for each column in Pandas + extrapolate values), I need to write a function, so it would expand the depth column / array for equal increments dz (in this case 0.5) towards zero (surface). Here the missing quotas are 0.15, 0.65 and 1.15

import numpy as np

depth = np.array([1.65, 2.15, 2.65, 3.15, 3.65, 4.15, 4.65, 5.15, 5.65, 6.15, 6.65, 7.15, 7.65, 8.15, 8.65])

Any ideas how to write a function so it does it each time for a different depth range ( i.e. depending on the varying minimum value)?

PEBKAC
  • 748
  • 1
  • 9
  • 28

1 Answers1

0

A very simple solution I did is:

depth_min = np.min(depth)
step = 0.5
missing_vals = np.arange(depth_min - step, 0, -step)[::-1]
depth_tot = np.concatenate((missing_vals, depth), axis=0)

I'm sure there exist better ways

PEBKAC
  • 748
  • 1
  • 9
  • 28