Skip to content
Advertisement

Tag: dataframe

Create rolling average pandas

I have a dataset of esports data like this: (done using pd.to_clipboard() I want to create a dataframe that essentially, for each team, every week, creates a rolling X game average of their points scored. (X could be 2, 3, 4, etc). A few notes: This example only shows points, the actual data has about 10 features that need rolling

Merging 2 different DataFrame with different length

I have two DataFrame Consists of time and price columns. I want to create a new DataFrame df3 as the length of df2, and I also want to put df1[‘price’] in it like below Where price1 shows the mean of price1 values for the corresponding time2 values like below I’m sorry if it’s unclear, but could you advise me on

Cleaner way to selectively multiply pandas DataFrame values

Given this example: Where the values in df are multiplied by non-NaN values from factors, is there a cleaner way to do this with pandas? (or numpy for that matter) I had a look at .mul(), but that doesn’t appear to allow me to do what’s required here. Additionally, what if factors contains rows with an id that’s not in

Pandas “A value is trying to be set on a copy of a slice from a DataFrame”

Having a bit of trouble understanding the documentation See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dfbreed[‘x’] = dfbreed.apply(testbreed, axis=1) C:/Users/erasmuss/PycharmProjects/Sarah/farmdata.py:38: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead Code is basically to re-arrange and clean some data to make analysis easier. Code in given row-by

Advertisement