How to get row number in dataframe in Pandas?

To get all indices that matches ‘Smith’ or as a numpy array or if there is only one and you want the integer, you can subset You could use the same boolean expressions with .loc, but it is not needed unless you also want to select a certain column, which is redundant when you only … Read more

Get a random sample with replacement

I have this list: and I want to get 4 random letters from it, but including repetition. Running this will only give me 4 unique letters, but never any repeating letters: How do I get a list of 4 colors, with repeating letters possible?

BeautifulSoup and lxml.html – what to prefer?

The simple answer, imo, is that if you trust your source to be well-formed, go with the lxml solution. Otherwise, BeautifulSoup all the way. Edit: This answer is three years old now; it’s worth noting, as Jonathan Vanasco does in the comments, that BeautifulSoup4 now supports using lxml as the internal parser, so you can … Read more