Skip to content

Commit 5774a2b

Browse files
committed
handle pandas groupby with group column in apply
1 parent 7e12639 commit 5774a2b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

pyxlma/lmalib/flash/properties.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def event_discharge_energy(z,area):
134134
eta_c = 0.004 #Scale the energy to depict the fraction of energy neutralized by
135135
#each flash in the capacitor model
136136
#Capacitor model:
137-
w = 4 * ((sigma_crit**2. * d * area.iloc[0])/(2* e)) #The quantity for appears when considering image charges (2*sigma)^2=4sigma^2
137+
w = 4 * ((sigma_crit**2. * d * area)/(2* e)) #The quantity for appears when considering image charges (2*sigma)^2=4sigma^2
138138
return(w*eta_c)
139139

140140

@@ -239,12 +239,12 @@ def flash_stats(ds, area_func=None, volume_func=None):
239239
# could only run on those where point counts meet threshold, instead
240240
# testing inside the function
241241
# Index of event_area and event_volume are event_parent_flash_id
242-
event_area = fl_gb.apply(area_func)
243-
event_volume = fl_gb.apply(volume_func)
242+
event_area = fl_gb.apply(area_func, include_groups=False)
243+
event_volume = fl_gb.apply(volume_func, include_groups=False)
244244

245245
#Compute flash discharge energy using parallel plate capacitor
246-
event_energy = fl_gb.apply(lambda df: event_discharge_energy(df['event_z'],
247-
event_area[df['event_parent_flash_id']]))
246+
event_energy = fl_gb.apply(lambda df1: event_discharge_energy(df1['event_z'],
247+
event_area[df1.name]), include_groups=False)
248248

249249

250250
# set the index for the original dataset's flash dimension to the flash_id

0 commit comments

Comments
 (0)