Reddy786 commited on
Commit
e60d8f2
·
verified ·
1 Parent(s): 3b97b2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -35,12 +35,14 @@ def calculate_volume_profile(data, row_layout):
35
  # Create a DataFrame for volume profile
36
  volume_profile = pd.DataFrame(0, index=bin_edges[:-1], columns=['Total Volume'])
37
 
38
- for index, row in data.iterrows():
 
39
  bin_indices = np.digitize([row['Low'], row['High']], bin_edges) - 1
40
- bin_indices = [max(0, min(bins-2, b)) for b in bin_indices]
41
 
42
- # Update the volume for the respective bin ranges
43
- volume_profile.iloc[bin_indices[0]:bin_indices[1] + 1, 0] += row['Volume']
 
44
 
45
  return volume_profile
46
 
 
35
  # Create a DataFrame for volume profile
36
  volume_profile = pd.DataFrame(0, index=bin_edges[:-1], columns=['Total Volume'])
37
 
38
+ for _, row in data.iterrows():
39
+ # Ensure the bin indices are integers
40
  bin_indices = np.digitize([row['Low'], row['High']], bin_edges) - 1
41
+ bin_indices = [int(max(0, min(bins - 2, b))) for b in bin_indices]
42
 
43
+ # Ensure bin_indices are valid for iloc slicing
44
+ if bin_indices[0] <= bin_indices[1]:
45
+ volume_profile.iloc[bin_indices[0]:bin_indices[1] + 1, 0] += row['Volume']
46
 
47
  return volume_profile
48