How to groupby multiple columns in pandas based on name?

Advertisements I want to create a new dataframe with columns calculated as means of columns with similar names from this dataframe: B6_i B6_ii B6_iii … BXD80_i BXD80_ii BXD81_i data … Cd38 0.598864 -0.225322 0.306926 … -0.312190 0.281429 0.424752 Trim21 1.947399 2.920681 2.805861 … 1.469634 2.103585 0.827487 Kpnb1 -0.458240 -0.417507 -0.441522 … -0.314313 -0.153509 -0.095863 Six1… Read More How to groupby multiple columns in pandas based on name?

Expandable Importrange

Advertisements I am combining several spreadsheets with identical layouts into one master, and want to create a way to have my query({importrange}) be dynamic, as I will be adding / removing some sheets as time goes on. I have all of my sheet addresses in column C, so my formula right now looks like: =QUERY({Importrange(C4,Sheet1!C5:F);Importrange(C5,Sheet1!C5:F);…}… Read More Expandable Importrange

Variables within a function

Advertisements Writing a function to calculate date based on relativedelta. How do I make the ‘frequency’ a variable? e,g, relativedelta(years=5), ability to define frequency: "years", "months", "days" etc.. Tried f-string literal but i think the apostrophe is giving issues. def date_ago(date, period, frequency): """date: "yyyy-mm-dd" frequency: "years", "months", "weeks", "days" period: interger """ date_ago =… Read More Variables within a function