Skip to content

Tag: pandas

How to vectorize pandas operation

I have a dataset of house sales with timestamped Periods(per quarter). I want to adjust the price according to the house pricing index change per region. I have a separate dataframe with 3 columns, the Quarter, the Region and the % change in price. I am currently achieving this by iterating over both datafram…

Label dataframe column with a list

I have a dataframe column text I would like to create another column term by matching it with a list [‘apple’, ‘banana, melon’] The result I get However, I expected it to be I sense that it might be because I use a list but I don’t know how to make a loop in lambda itself Answer …

Replace rows with different number of characters

I have a column having strings of different number of characters. Most of rows have the following number of characters: but there are also rows having different number, for instance I would like to replace those columns that have a number of characters different from xx.xx.xxxx xx-xx-xx with a null value (e.g…

Equidistant timeseries filling the blanks

I have the following code that generates a timeseries with 1 min steps but would like to have the time gaps filled. i.e 13:58 is missing in between. Every ip should be represented in the gap with zero values. How can this be achieved? Answer First change unstack by first level for DatetimeIndex, and add DataF…