Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple pandas question
#3
(Nov-30-2021, 03:13 AM)jefsummers Wrote: Yes, a bit messy and I am sure can be simplified, but it is unclear to me what you want to do. Can you explain better (words, I see the code)?

I have a dataframe with 1000 columns all with the same length (365 values), and I need to calculate de moving average of each column. But I need to do this for diferent periods, from 1 to 100. A period is the pandas.DataFrame.rolling function first parameter.
So for each of the 1000 columns (years) I need to get 100 new datasets (They will have a diferent length with the increase of the moving average period, this is the reason why I can´t use a numpy array instead of a dataframe)


In my code I´m doing the following:

1) tm1, tm2 and tm3 are the moving averages considering a period of 1, 2 and 3 for each of the nine columns. I need to do this until I reach tm100...
2) Then I´m using concat() to create a single dataframe.
3) I´m using re.search() to reorganize the columns by year.
4) Export to excel.


Thank you
Reply


Messages In This Thread
Simple pandas question - by mcva - Nov-25-2021, 12:26 PM
RE: Simple pandas question - by jefsummers - Nov-30-2021, 03:13 AM
RE: Simple pandas question - by mcva - Nov-30-2021, 02:15 PM
RE: Simple pandas question - by jefsummers - Dec-05-2021, 01:51 PM
RE: Simple pandas question - by mcva - Dec-17-2021, 04:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pandas df inside a df question mbaker_wv 4 1,240 Dec-25-2022, 01:11 AM
Last Post: mbaker_wv
  Pandas usecols question rsearing 1 1,294 Aug-20-2022, 10:10 PM
Last Post: jefsummers
  Simple question (I guess) tchadrack 1 1,355 Jan-08-2022, 06:36 AM
Last Post: buran
  Pandas question new2datasci 0 1,992 Jan-10-2021, 01:29 AM
Last Post: new2datasci
  Pandas merge question smw10c 2 5,792 Jul-02-2020, 06:56 PM
Last Post: hussainmujtaba
  Counting Criteria in Pandas Question Koenig 1 2,218 Sep-30-2019, 05:16 AM
Last Post: perfringo
  Simple String to Time within a pandas dataframe Ecniv 1 2,555 Jun-14-2019, 03:25 AM
Last Post: scidam
  Function question using Pandas smw10c 7 7,218 Feb-12-2019, 06:52 PM
Last Post: Nathandsn
  Simple pandas dataframe question popohoma 1 3,601 Jan-03-2019, 05:00 PM
Last Post: ashlardev
  question on pandas datareader kit12_31 3 9,314 Feb-05-2018, 11:55 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020