On Wednesday, July 4, 2018 at 7:51:19 PM UTC-7, Viswanath Potluri wrote:
> I've a dataframe all_paths with say 9000 rows, and i've another dataframe 
> Legs with 4000 rows. I need to filter all_paths dataframe based on a column 
> called 'itineraries' which contains a list of strings, for each row in Legs. 
> So, basically its like getting a dataframe that is subset of all_paths for 
> each row in Legs. Then I need to perform a math operation on the columns of 
> each subset and assign the values back to another column in all_paths. 
> Following is my implementation
> 
> def step1_vec(iti_list, idx):
>   mask= all_paths.loc[all_paths['Path'].isin(iti_list)]
>   Legs.loc[idx,'r']=np.dot(mask['demand'].values, mask['u'].values.T)
>   Legs.loc[idx, 't']= Legs.loc[idx, 'k']/Legs.loc[idx, 'r']
> 
> def step2():
>   not_full_legs=Legs.loc[(~Legs['Leg ID'].isin(full_legs))&(Legs['t']<1)]
>   np.vectorize(step1_vec 
> (not_full_legs['itineraries'].values,not_full_legs.index.values)

does someone has a solution for my question??
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to