Python Forum
add the suffix to the next line - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: add the suffix to the next line (/thread-35709.html)



add the suffix to the next line - Paulman - Dec-04-2021

Hi,

Does anybody know the shortest command to add a suffix to the header of several columns below the header and not on the same line?

I have the dataframe below:

   Type     Price1     Price2     Price3      Price4      Price5      
0    A       5.467     17.450     14.340     233.440     143.550
1    B      12.347     33.776     19.700     443.335     119.450
and if I use add_suffix(' USD'), it adds the USD on the same line:

   Type     Price1 USD     Price2 USD     Price3 USD      Price4 USD      Price5 USD      
0    A           5.467         17.450         14.340         233.440         143.550
1    B          12.347         33.776         19.700         443.335         119.450
While I want the USD in the line below of the prices:

   Type     Price1     Price2     Price3      Price4      Price5      
               USD        USD        USD         USD         USD
0    A       5.467     17.450     14.340     233.440     143.550
1    B      12.347     33.776     19.700     443.335     119.450



RE: add the suffix to the next line - BashBedlam - Dec-04-2021

Wouldadd_suffix('\n USD'do what you want?


RE: add the suffix to the next line - Paulman - Dec-05-2021

Thanks, already tried and it would have been too nice if it worked Cry .... the \n when used in the add_ suffix or add_prefix is treated like a text within the ' ' and not as a command like in print().

After digging a lot in the Internet I think that this matter is much more complicated than an easy command to add somewhere in the code!!