Michael
Michael

Reputation: 559

same string from all the row python

I have some data, the first column is the login, the second column is comment which is string or numbers or both, the data is this:

Login Comment
256   qq456
257   msn176453

I want to find all the rows that the the begining of the comment is qq. I was trying to use:

sentence_begining = r"[qq.]"
re.findall(sentence_begining, orders["Comment"])

however,this way failed, after googling a lot, I still cannot solve this problem. So I am wondering others may also have this question, so post it here. Many thanks

Upvotes: 0

Views: 33

Answers (1)

gseva
gseva

Reputation: 373

Try using str.startswith:

orders[orders['Comment'].str.startswith('qq')]

Upvotes: 3

Related Questions