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


Groups > comp.lang.python > #86737

Re: date

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: date
Date 2015-03-02 14:26 +0000
References <slrnmf8hqo.6hg.maus@gmaus.info> <md1ks9$epb$1@speranza.aioe.org>
Newsgroups comp.lang.python
Message-ID <mailman.40.1425306406.13471.python-list@python.org> (permalink)

Show all headers | View raw


On 02/03/2015 12:25, Fabien wrote:
> On 02.03.2015 12:55, greymausg wrote:
>> I have a csv file, the first item on a line is the date in the format
>> 2015-03-02 I try to get that as a date by date(row[0]), but it barfs,
>> replying "Expecting an integer". (I am really trying to get the offset
>> in weeks from that date to today())
>
> Have you tried Pandas? http://pandas.pydata.org/
>
> If your csv file has no other problems, the following should do the trick:
>
> import pandas as pd
> df = pd.read_csv('file.csv', index_col=0, parse_dates= {"time" : [0]})
>
> Cheers,
>
> Fabien
>

IMHO complete overkill.  Give me the Steven D'Aprano solution any day of 
the week.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

date greymausg <maus@mail.com> - 2015-03-02 11:55 +0000
  Re: date Fabien <fabien.maussion@gmail.com> - 2015-03-02 13:25 +0100
    Re: date Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-02 14:26 +0000
      Re: date Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-03 01:44 +1100
        Re: date Tim Golden <mail@timgolden.me.uk> - 2015-03-02 14:50 +0000
        Re: date Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-02 15:24 +0000
        Re: date Chris Angelico <rosuav@gmail.com> - 2015-03-03 02:51 +1100
          Re: date alister <alister.nospam.ware@ntlworld.com> - 2015-03-02 16:09 +0000
            Re: date Chris Angelico <rosuav@gmail.com> - 2015-03-03 03:25 +1100
            Re: date Dave Angel <davea@davea.name> - 2015-03-02 13:32 -0500
        Re: date Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-02 16:44 +0000
      Re: date Fabien <fabien.maussion@gmail.com> - 2015-03-02 16:42 +0100
        Re: date Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-02 16:41 +0000
    Re: date greymausg <maus@mail.com> - 2015-03-02 14:49 +0000
  Re: date Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-02 23:45 +1100
    Re: date greymausg <maus@mail.com> - 2015-03-02 14:49 +0000
      Re: date greymausg <maus@mail.com> - 2015-03-02 17:55 +0000

csiph-web