Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86760
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'string': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'yeah,': 0.09; 'python': 0.11; 'suggest': 0.14; 'language.': 0.14; 'background,': 0.16; 'csv': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'stdlib.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'file,': 0.19; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'cheers,': 0.24; "i've": 0.25; 'least': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'originally': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; 'week.': 0.33; 'convert': 0.35; 'but': 0.35; "i'll": 0.36; 'url:org': 0.36; 'should': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'read': 0.60; 'life,': 0.60; 'hope': 0.61; 'first': 0.61; 'complete': 0.62; 'such': 0.63; 'myself': 0.63; 'our': 0.64; 'telling': 0.64; 'charset:windows-1252': 0.65; 'day': 0.76; 'received:2': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: date |
| Date | Mon, 02 Mar 2015 16:41:52 +0000 |
| References | <slrnmf8hqo.6hg.maus@gmaus.info> <md1ks9$epb$1@speranza.aioe.org> <mailman.40.1425306406.13471.python-list@python.org> <md20cs$er0$1@speranza.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-2-98-199-155.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
| In-Reply-To | <md20cs$er0$1@speranza.aioe.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| 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.53.1425314529.13471.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1425314529 news.xs4all.nl 2942 [2001:888:2000:d::a6]:43205 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:86760 |
Show key headers only | View raw
On 02/03/2015 15:42, Fabien wrote:
> On 02.03.2015 15:26, Mark Lawrence wrote:
>>>
>>> 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.
>
> Without knowing anything about the OP background, I still hope my
> suggestion is a good one. Pandas is one of the best thing that happened
> to me in my python life, I'm happy to at least suggest it. But yeah, if
> you just want to read the csv and do no data crunching on it, pandas is
> "overkill".
>
> Fabien
I've used pandas myself and I'll admit to being very impressed. However
the OP originally said '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".' Without
finding out exactly what the OP is trying to achieve, telling them to
download a package such as pandas just to convert a string to a date is
overkill when there's a solution in the stdlib.
--
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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