Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83237
| References | <CAOmh463bQr2zrcNneMS3xt6SLK4JV+1oYGQRv_DX_7h66GqvSw@mail.gmail.com> |
|---|---|
| Date | 2015-01-05 23:13 +1100 |
| Subject | Re: how to select all the monday form "20150101" till "20150620"? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17392.1420459989.18130.python-list@python.org> (permalink) |
On Mon, Jan 5, 2015 at 4:49 PM, length power <elearn2014@gmail.com> wrote:
> import pandas as pd
> rng = pd.date_range("20150101","20150620",freq="D")
> for day in rng:
> x = pd.to_datetime(day)
> y = x.timetuple().tm_wday
> if(y == 0) :print(x.strftime("%Y%m%d"))
>
>
> I have selected all the monday form "20150101" till "20150620",how to make
> it more simple?
I'm not sure, but I suspect your freq="D" parameter means that it
gives you sequential days. If you start at 20150105 (which is a
Monday), and change that to freq="W" or possibly freq="7D", it might
work just like that. Hint: Have you looked at the pandas
documentation?
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: how to select all the monday form "20150101" till "20150620"? Chris Angelico <rosuav@gmail.com> - 2015-01-05 23:13 +1100
csiph-web