Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #83237 > unrolled thread

Re: how to select all the monday form "20150101" till "20150620"?

Started byChris Angelico <rosuav@gmail.com>
First post2015-01-05 23:13 +1100
Last post2015-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.


Contents

  Re: how to select all the monday form "20150101" till "20150620"? Chris Angelico <rosuav@gmail.com> - 2015-01-05 23:13 +1100

#83237 — Re: how to select all the monday form "20150101" till "20150620"?

FromChris Angelico <rosuav@gmail.com>
Date2015-01-05 23:13 +1100
SubjectRe: 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web