Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to pass in f-string inside another string in dataframe series

How does one pass the number 6 defined as a string into 'text2=self.nmb' where self.nmb is a method attribute

self.nmb='6'
X = pd.DataFrame({'A':['text1', 'text2=f'{self.nmb}'']})
print(X)

Desired output

           A
0      text1
1    text2=6

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use:

In [1232]: nmb='6'

In [1235]: X = pd.DataFrame({'A':['text1', f'text2={nmb}']})

In [1236]: X
Out[1236]: 
         A
0    text1
1  text2=6
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading