Pandas data frame Concatenate and Sorting the Index

I have a dataframe with one categorical column, I divided dataframe to do manipulation depending on category now want to merge the dataset,

index A   B   C   
 1    M   2.2 3.4 
 2    F   3.4 1.0
 3    M   3.0 2.1
  .
  .
  .

created two new dataframe

index A   B   C   
 1    M   2.2 3.4 
 3    M   3.0 2.1
      .
      .
      .



   index A   B   C   
     2   F   3.4 1.0
          .
          .
          .

I want to get the resultant output as:

index A   B   C    D
 1    M   2.2 3.4  2.8
 2    F   3.4 1.0  3.4
 3    M   3.0 2.1  2.05
      .
      .
      .

I tried to do merge and concat but not getting desired solution.



Read more here: https://stackoverflow.com/questions/64399073/pandas-data-frame-concatenate-and-sorting-the-index

Content Attribution

This content was originally published by mishy at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: