Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72759
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fomcl@yahoo.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | UNSURE 0.217 |
| X-Spam-Level | ** |
| X-Spam-Evidence | '*H*': 0.58; '*S*': 0.01; 'column': 0.07; 'oh,': 0.09; 'subject:question': 0.10; 'def': 0.12; 'advance!': 0.16; 'thoughts?': 0.16; 'valueerror': 0.16; 'index': 0.16; 'trying': 0.19; 'code,': 0.22; 'import': 0.22; 'conjunction': 0.24; 'looks': 0.24; 'tried': 0.27; 'function': 0.29; 'gives': 0.31; 'header:Received:9': 0.33; 'something': 0.35; 'but': 0.35; 'data,': 0.36; 'date.': 0.36; 'done': 0.36; 'thanks': 0.36; 'possible': 0.36; 'hi,': 0.36; 'system,': 0.38; 'to:addr:python- list': 0.38; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'remove': 0.60; 'received:98.137': 0.60; 'lower': 0.61; 'new': 0.61; 'rates': 0.61; 'day.': 0.63; 'interest': 0.64; 'within': 0.65; 'header:Reply-To:1': 0.67; 'apart': 0.72; 'records': 0.73; 'upper': 0.74; 'nice,': 0.84; 'received:98.138.229': 0.84; 'us?': 0.84; 'medicine,': 0.91; 'education,': 0.96 |
| X-Yahoo-Newman-Property | ymail-4 |
| X-Yahoo-Newman-Id | 123730.57538.bm@omp1022.mail.gq1.yahoo.com |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1401997250; bh=D9c002YtypbaaLiYvEJZgk+e22vuRg9gN1EM9WtOIzA=; h=Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=YX0aDOYe94RCMG89GjEHjzMewZ0nk29geMrS3bbUK1aqaNHiI+P4oOyh0PwhBzFgKPxSn474rqCQnCuVchRoraspffwcQYiOCnIaOlH66Ed4VX+QGRRgOSqvjNGiLJBiAhsb1V822GGGm1QjhgUUDorVDR45EvDb5BaUXxqGwoM= |
| X-YMail-OSG | QEduA9wVM1kV3NhWy56WfoAUYPHmMr3OwdpATRiRi2SkVNU avSHQhIBzJa.RfiMEMZuXqOscuTMlTx0mv6BswX6gKMJUFlhTQl6k4qUsNxJ xGxeWjQtVSE53QMSImvswzwCxytbN2LfyhDUnkQNR6qVy_fhz6EYLk1IMwnK UQZ0cQGeX31LNIIrb2rvNPnBB82KJbYMwAGBWc2gTIzHikKcC9qrU5_q1Sp9 BW14FwuOegn0tGFrYiu2lSWdEQWkfTouCM_pIJIe4iuzXy1xgpNvi4HzAV2q 2tCrNWOSn5kmS2YKDKG86LZu3MCA2w65h6WbYZqmTbOOMSPBP7XqqPUMyGMN 2UZPJARNXnZ2kXpXizK6ajFFlfp8HRkw4SAds_ejganITqtTcqebJ_oPI3IK IvD.x8UhCod8Ffuk_WUQ7CjwdyVtJzhtuMTQdL8pj3pBhBhyhyBBVj7HeUui WNub4JSO57fcuLNlREwc5wKC93XubFxF_ZeXTmXq8zBewfFV9Re6Ttawf.n6 OsbMXFfMDAARQMH3xO3L5GB_3J62PCXPWUxVt7eqmDfcJgX1_Cn.LtgDGHw- - |
| X-Rocket-MIMEInfo | 002.001, SGksCgpJIGFtIG5ldyB0byBQYW5kYXMuIEkgYW0gdHJ5aW5nIHRvIHJlbW92ZSB0aGUgbG93ZXIgYW5kIHVwcGVyIDE1IHBlcmNlbnRpbGVzIG9mIGludGVyZXN0IHJhdGVzIHdpdGhpbiBhIGRheS4gVGhlIGluZGV4IGNvbHVtbiBpcyB0aGUgZGF0ZS4gQmVsb3cgaXMgc29tZSBjb2RlLCBidXQgaG93IGRvIEkgYXBwbHkgdGhlIHRyaW0gZnVuY3Rpb24gZGF5LWJ5LWRheT8gSSB0cmllZCB1c2luZyBncm91cGVkKCkgaW4gY29uanVuY3Rpb24gd2l0aCBhcHBseSgpLCBidXQgdGhhdCB0dXJuZWQgb3V0IHRvIGIBMAEBAQE- |
| X-Mailer | YahooMailWebService/0.8.190.668 |
| Date | Thu, 5 Jun 2014 12:40:49 -0700 (PDT) |
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
| Subject | Pandas question |
| To | Python <python-list@python.org> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-Mailman-Approved-At | Thu, 05 Jun 2014 22:21:36 +0200 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | Albert-Jan Roskam <fomcl@yahoo.com> |
| 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.10765.1401999697.18130.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1401999697 news.xs4all.nl 2975 [2001:888:2000:d::a6]:56118 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:72759 |
Show key headers only | View raw
Hi,
I am new to Pandas. I am trying to remove the lower and upper 15 percentiles of interest rates within a day. The index column is the date. Below is some code, but how do I apply the trim function day-by-day? I tried using grouped() in conjunction with apply(), but that turned out to be an efficient way to slow my computer down and choke it. Any thoughts?
import pandas as pd
records = pd.read_table("blah.csv", sep=";", parse_dates=[2], index_col=2, low_memory=False)
def trim(df, colname, boundaries=(0.15, 0.85)):
lo = df[colname] >= df[colname].quantile(boundaries[0])
hi = df[colname] <= df[colname].quantile(boundaries[1])
return df[lo & hi]
trimmed = trim(records, 'pct_12m') # this trims across all data, not day-by-day, which I want.
Oh, and is something like the following possible instead of df[lo & hi]?
df[lo <= df[colname] <= hi] # looks nice, but gives ValueError
Thanks in advance!
Regards,
Albert-Jan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Pandas question Albert-Jan Roskam <fomcl@yahoo.com> - 2014-06-05 12:40 -0700
csiph-web