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


Groups > comp.lang.python > #83237

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'subject:form': 0.07; 'parameter': 0.09; 'sure,': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hint:': 0.16; 'sequential': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'skip:p 40': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'possibly': 0.26; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'gives': 0.31; 'that.': 0.31; 'subject:all': 0.32; 'subject:the': 0.34; 'monday': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'pm,': 0.38; 'subject:" ': 0.39; 'length': 0.61; 'till': 0.61; 'more': 0.64; 'day': 0.76; 'power': 0.76; '2015': 0.84; 'skip:: 20': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=mzBsJOth7Ze3sZjJ263GgzjAdO7DQOsqg53J5D9DZgA=; b=SzIqS+xCjYdzRo5eT5/B4fuZVDJtiM+hwsRbn4jS9V8YFgP5z9E1XiM880HuSw2liz icQ91NNRSdY9m7GNFzDUWIEpXeuEYFvjZW8nUDcrV8sEA2+LZ11bg+G/Lo/PwiC3QqsZ 2YE3gf95TtLIY/LMtqlKMXkfbT2xF0TY33abEJXys9Gnf0Y2Mjl67O0lnXcPM9DWt1/6 AhSeq8e5w+d1NgMHzL6K+hOV/ewFgoIoyjYiDJL3WwLtppN4xzTlZKy1L+9lwuOvTo+M gonqxJdzTJ086heol0UsOhGyVJYOieekjFECrQ0ILXth3BMjbvEZUSvOfAwkBlv8urGB lBUQ==
MIME-Version 1.0
X-Received by 10.42.52.200 with SMTP id k8mr56675170icg.26.1420459987379; Mon, 05 Jan 2015 04:13:07 -0800 (PST)
In-Reply-To <CAOmh463bQr2zrcNneMS3xt6SLK4JV+1oYGQRv_DX_7h66GqvSw@mail.gmail.com>
References <CAOmh463bQr2zrcNneMS3xt6SLK4JV+1oYGQRv_DX_7h66GqvSw@mail.gmail.com>
Date Mon, 5 Jan 2015 23:13:07 +1100
Subject Re: how to select all the monday form "20150101" till "20150620"?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17392.1420459989.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1420459989 news.xs4all.nl 2977 [2001:888:2000:d::a6]:47937
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:83237

Show key headers only | View raw


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


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