Pandas Using Sort_values To Sort 2 Dataframes Then Sub-sort By Date
I have two dataframes consisting a similar type of informatio. I'm attempting to merge them toghether and reorganize them. Here is a sample of the dataframes: df1 = Member Nbr
Solution 1:
by
parameter can be a list of columns so that the dataframe is first sorted by the first column (and for ties by the second column, and for ties by the third column etc.)
df12.sort_values(by=['Member Nbr', 'Date-Join'], inplace=True)
produces
MemberNbrName-FirstName-LastDate-Join020ZoeSoumas2011-08-0113128 JulienBougie2011-07-2223535 MichelBibeau2015-02-1843762 RobertOrtopan2010-01-3133762 RobertOrtopan2010-02-2863892 ChristianBurnet2010-03-2453892 ChristianBurnet2010-04-2474116 ChristopherDuthie2014-12-0284700 ManojChauhan2014-11-1194802 AnnaBalian2014-07-26105004 AbdullahCekic2012-03-12125022 RobertNgabirano2010-06-25115022 RobertNgabirano2010-07-28135130 RaymondeGirard2011-01-04
Note that for this to work correctly, Date-Join column should be of type datetime.
Post a Comment for "Pandas Using Sort_values To Sort 2 Dataframes Then Sub-sort By Date"