Skip to content

Tag: pandas

How to search for name in dataframe

For example I want to find all the people that has “Abbott” in their name df.loc[name in df[“Name”]] I tried this and it didn’t work Answer You can use str.contains with the column you are interested in searching

Transform dataframe format

How do I convert the following dataframe from df1 to df2? Thanks in advance! Answer You could try as follows. Apply .str.split to columns a and b in a loop, each time exploding the result. This will get us 2 pd.Series and we use pd.concat to put them together. After this, we just need to assign col c, and res…