Using pd.concat instead of df.append with pandas 1.4

We Are Going To Discuss About Using pd.concat instead of df.append with pandas 1.4. So lets Start this Python Article.

Using pd.concat instead of df.append with pandas 1.4

  1. How to solve Using pd.concat instead of df.append with pandas 1.4

    Use pd.concat like this. Convert your inner command to df using Series.to_frame and then transpose it using df.T:
    In [74]: pd.concat([table, table.iloc[-1].pct_change(periods=1, fill_method=None).fillna('').apply(lambda x: '{:.1%}'.format(x) if x else '').to_frame().T]) Out[74]: C large small All A B bar one 4 5 9 two 7 6 13 foo one 4 1 5 two 0 6 6 All 15 18 33 20.0% 83.3%

  2. Using pd.concat instead of df.append with pandas 1.4

    Use pd.concat like this. Convert your inner command to df using Series.to_frame and then transpose it using df.T:
    In [74]: pd.concat([table, table.iloc[-1].pct_change(periods=1, fill_method=None).fillna('').apply(lambda x: '{:.1%}'.format(x) if x else '').to_frame().T]) Out[74]: C large small All A B bar one 4 5 9 two 7 6 13 foo one 4 1 5 two 0 6 6 All 15 18 33 20.0% 83.3%

Solution 1

Use pd.concat like this. Convert your inner command to df using Series.to_frame and then transpose it using df.T:

In [74]: pd.concat([table, table.iloc[-1].pct_change(periods=1, fill_method=None).fillna('').apply(lambda x: '{:.1%}'.format(x) if x else '').to_frame().T])
Out[74]: 
C       large  small    All
A   B                      
bar one     4      5      9
    two     7      6     13
foo one     4      1      5
    two     0      6      6
All        15     18     33
               20.0%  83.3%

Original Author Mayank Porwal Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment