Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83237 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2015-01-05 23:13 +1100 |
| Last post | 2015-01-05 23:13 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: how to select all the monday form "20150101" till "20150620"? Chris Angelico <rosuav@gmail.com> - 2015-01-05 23:13 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-01-05 23:13 +1100 |
| Subject | Re: how to select all the monday form "20150101" till "20150620"? |
| Message-ID | <mailman.17392.1420459989.18130.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web