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

Selecting specific columns in where condition using Pandas

I have a below Dataframe with 3 columns:

df = DataFrame(query, columns=["Processid", "Processdate", "ISofficial"])

In Below code, I get Processdate based on Processid==204 (without Column Names):

result = df[df.Processid == 204].Processdate.to_string(index=False)

But I wan the same result for Two columns at once without column names, Something like below code:

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

result = df[df.Processid == 204].df["Processdate","ISofficial"].to_string(index=False)

I know how to get above result but I dont want Column names, Index and data type.
Can someone help?

>Solution :

I think you are looking for header argument in to_string parameters. Set it to False.

df[df.Processid==204][['Processdate', 'ISofficial']].to_string(index=False, header=False)
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