Home > Software design >  Selecting specific columns in where condition using Pandas
Selecting specific columns in where condition using Pandas

Time:06-28

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:

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?

CodePudding user response:

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)
  • Related