Skip to content

Tag: pandas

Split Series of tuples into multiple columns

I have a series of tuples of the form (‘Name’, Number), and I would like to split them into two columns, one being the name, the other being the number. I’d like to end up with something like this: I’ve tried a few iterations of splitting strings, applying a lambda function, etc, and c…

Longitude and Latitude Distance Calculation between 2 dataframes

I have the following two dataframes. Call this df1 and call this one df2 I want to know how I can calculate the distance between place and all cities listed. So it should look something like this. I’m reading through this particular post and attempting to adapt:Pandas Latitude-Longitude to distance betw…

Plot multiple lines in subplots

I’d like to plot lines from a 3D data frame, the third dimension being an extra level in the column index. But I can’t manage to either wrangle the data in a proper format or call the plot function appropriately. What I’m looking for is a plot where many series are plotted in subplots arrang…

Calculate 14-day rolling average on data with two hierarchies

I am trying to calculate the 14 day rolling average for retail data with multiple different hierarchies. The ‘Store’ dataframe looks like this: What I am trying to do is create a rolling 14 day average for the purchases column for each store. The data extends well past 14 day (over 8 months), and …