Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106886
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Daiyue Weng <daiyueweng@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | python pandas convert strings to datetime problems |
| Date | Mon, 11 Apr 2016 17:08:39 +0100 |
| Lines | 20 |
| Message-ID | <mailman.32.1460390927.15650.python-list@python.org> (permalink) |
| References | <CAF_EDkvyR4Ri7R+pEWNQdEenVi6pir9zGC6ZKew2eCw93ZuJ8Q@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de kqJauB7dIj6mCyhBpLWh1wLWdxfZqDXgPRGc+6NkTnJw== |
| Return-Path | <daiyueweng@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.058 |
| X-Spam-Evidence | '*H*': 0.89; '*S*': 0.00; 'subject:problems': 0.09; 'subject:python': 0.14; '(meaning': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:5 70': 0.16; 'skip:n 110': 0.16; '<': 0.18; '>': 0.18; 'issue.': 0.20; 'converted': 0.22; 'compare': 0.27; 'message-id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'values': 0.28; 'fine': 0.28; '8bit%:2': 0.29; 'code': 0.30; 'skip:d 20': 0.34; 'received:google.com': 0.35; 'i.e.': 0.35; 'skip:p 30': 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'created': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'thanks': 0.37; 'received:209': 0.38; 'wrong': 0.38; 'hi,': 0.38; 'to:addr:python.org': 0.40; 'series': 0.65; 'sans': 0.72; 'now).': 0.84; 'vera': 0.84; '1970': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=ZMR/xpRukPDnvBufqIzR5B0AUYgIu496VRbIvXTDi+c=; b=SD/CgMCJvx7yDnwgCbCCPqRccCHYqQt0QsB9Mh8nyOQFU1dyr71uoCsg2ETJ7O9+K1 HpaEk4Pn72L3RjwCICH0yAmxl/OB8OOXAqMf/LZf3cFMzVdg5otcFmpwA0B4YS1hpKYo +BYBKBTL3FMqegFQ+zTzrXin6C27sKj5h510A+91kUJE7MeLXePHr9WHUmkIqHzXf3po Ixajbe6D+MMbhnZDogY1MYRVGDhq57Qrm/8M00JOKSYUOya+r1nJdFNou3zhfRy0I/fp cXeCsFXzSwxM4ltChfr8QzEYiJhNOjXTqjGsAlNSIRNizQjqEMD+nn+DKoChK2nTPVsi tY4A== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=ZMR/xpRukPDnvBufqIzR5B0AUYgIu496VRbIvXTDi+c=; b=Mkl63QznAjO9ZMbWQVxywaL9gniLW8HkGoubkRAmagckpzYVGhrLlpmmOlf9eg65To +6UgGqQA1WI3ybS8F0at8PpTEiIoiEheBaILxcEfxCIY2myf46C1eW3SEkeRtw2vJudb Ef9r41Y5r6uoTA52xIrSUPBSkViG2rASxCEysC2RmBix7qPTPj9M8dD/izW/8kLgr7Xt 2fFm5fTIIJJYdpf0TD9H+jM3K3goe7aaXpTXh3IuLnEauhPOY41DXfeKk/vKquoGBNuR hsqzAty4cF4k0+l2m/wOf0g1I0bhr985pW2iKU5MrsqRvKXKiAX7Pp1GuqiKf3U9bMsL czow== |
| X-Gm-Message-State | AD7BkJKprWF6txrNoHf8GEQFzR52a0oRtC8fob9XDSxKDun+qrshMtac5Wfz/8mo7GHify6D392fxq/eC1OO4A== |
| X-Received | by 10.112.157.105 with SMTP id wl9mr8819350lbb.137.1460390920027; Mon, 11 Apr 2016 09:08:40 -0700 (PDT) |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| 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> |
| X-Mailman-Original-Message-ID | <CAF_EDkvyR4Ri7R+pEWNQdEenVi6pir9zGC6ZKew2eCw93ZuJ8Q@mail.gmail.com> |
| Xref | csiph.com comp.lang.python:106886 |
Show key headers only | View raw
Hi, I need to compare the years in a Series. The values in the Series is like '1996', '2015', '2006-01-02' or '20130101' etc. The code I created is, col_value_series = pd.to_datetime(col_value_series, infer_datetime_format=True) min_year = col_value_series.min().year max_year = col_value_series.max().year current_year = datetime.date.today().year res1 = min_year > 1970 res2 = max_year < current_year return min_year > 1970 and max_year < current_year the code is working fine on the values like '20030101' and '2006-01-02', which are converted to datetime, i.e. '2003-01-01'. But it converted values '1996' or '2015' to '1970-01-01 00:00:00.000001996' and '1970-01-01 00:00:00.000002015', which are completely wrong (meaning the years are all 1970 now). So how to resolve the issue. thanks
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
python pandas convert strings to datetime problems Daiyue Weng <daiyueweng@gmail.com> - 2016-04-11 17:08 +0100
csiph-web