Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

19 May, 2024: Line wrapping has been changed to be more consistent with Usenet standards.
 If you find that it is broken please let me know here rocksolid.nodes.help


devel / comp.lang.python / Re: double bracket integer index in pandas; Is this a legal syntax

SubjectAuthor
o double bracket integer index in pandas; Is this a legal syntaxCameron Simpson

1
Re: double bracket integer index in pandas; Is this a legal syntax

<mailman.27.1683167922.13552.python-list@python.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24112&group=comp.lang.python#24112

  copy link   Newsgroups: comp.lang.python
Path: rocksolid2!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: double bracket integer index in pandas; Is this a legal syntax
Date: Thu, 4 May 2023 12:29:45 +1000
Lines: 48
Message-ID: <mailman.27.1683167922.13552.python-list@python.org>
References: <CAP0EqC_+8wi+3DYQ8hzn6qKdTT3wg8AujRWFGS0yR3TyawujVg@mail.gmail.com>
<ZFMYmbZsWxrD/ma2@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de ABpTMLFDgStxGd/xATBg0AmF/TjAMltnsjMC831gD/UQ==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url-ip:140.82.114/24':
0.03; 'url-ip:140.82/16': 0.03; 'spaces': 0.07; ':-)': 0.09;
'dataframe': 0.09; 'describe': 0.09; 'pandas': 0.09; 'set,': 0.09;
'cheers,': 0.11; 'url:github': 0.14; 'url-ip:140/8': 0.15; '>>>>':
0.16; 'cameron': 0.16; 'columns': 0.16; 'forever.': 0.16;
'from:addr:cs': 0.16; 'from:addr:cskk.id.au': 0.16;
'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net':
0.16; 'simpson': 0.16; 'skip:> 10': 0.16; 'subject:; ': 0.16;
'subject:integer': 0.16; 'subject:syntax': 0.16; 'subset': 0.16;
'wrote:': 0.16; 'python': 0.16; 'to:addr:python-list': 0.20;
'code': 0.23; 'skip:p 30': 0.23; 'student': 0.24; '(and': 0.25;
'section': 0.25; 'suspect': 0.26; 'series': 0.28; 'header:User-
Agent:1': 0.30; 'attaching': 0.32; "i'll": 0.33; 'someone': 0.34;
'header:In-Reply-To:1': 0.34; 'author': 0.37; 'this.': 0.37;
'use': 0.39; 'data.': 0.40; 'our': 0.64; 'came': 0.65;
'received:userid': 0.66; 'subject:this': 0.67;
'header:Received:6': 0.67; 'per': 0.68; 'video': 0.68; 'clarity':
0.69; 'analysis': 0.69; 'content.': 0.70; 'received:172.16': 0.76;
'selecting': 0.76; 'indices': 0.84; 'so:': 0.84; 'country': 0.88;
'number.': 0.91
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <CAP0EqC_+8wi+3DYQ8hzn6qKdTT3wg8AujRWFGS0yR3TyawujVg@mail.gmail.com>
User-Agent: Mutt/2.2.7 (2022-08-07)
X-tce-id: cskk@bigpond.com
X-tce-ares-id: ares-e{6a5f4489-749d-46d1-a9be-e45de1ac8e7b}1
X-tce-spam-action: no action
X-tce-spam-score: 0.0
X-Cm-Analysis: v=2.4 cv=Xoc8e3J9 c=1 sm=1 tr=0 ts=6453189c
a=mbc/ifZLY0WHpzGyqaaTRA==:117 a=mbc/ifZLY0WHpzGyqaaTRA==:17
a=kj9zAlcOel0A:10 a=P0xRbXHiH_UA:10 a=pGLkceISAAAA:8 a=NEAV23lmAAAA:8
a=Vnv60LJWr-F9oJwPGUEA:9 a=CjuIK1q_8ugA:10
X-Cm-Envelope: MS4xfD9FXsrogmHmm6FuhAgf0LKGp4/8XAi79KDmV7EzSz7bJ7i/w0Ps8PboQlSo24AgamwYohKVpcAxAyt0pN4AePLjT88bps88WVX1mGQqcgxXOPb6UOAn
rkvakP80WRqxM9dkqL9qWexWO+o/ZhbtZaFuySTsCvorGAHD5bsOXwx52aV18OugCX5jSN4gUh+hOg==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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: <ZFMYmbZsWxrD/ma2@cskk.homeip.net>
X-Mailman-Original-References: <CAP0EqC_+8wi+3DYQ8hzn6qKdTT3wg8AujRWFGS0yR3TyawujVg@mail.gmail.com>
 by: Cameron Simpson - Thu, 4 May 2023 02:29 UTC

On 03May2023 17:52, Artie Ziff <artie.ziff@gmail.com> wrote:
>The code came from a video course, "Pandas Data Analysis with Python
>Fundamentals" by Daniel Chen.
>
>I am curious why the author may have said this. To avoid attaching
>screenshots, I'll describe this section of the content. Perhaps someone can
>say, "oh that's how it used to work"... haha

Unlikely; Python indices (and by implication Pandas indices) have
counted from 0 since forever. I suspect just a typo/braino.

>D.CHEN:
>"You can also subset the columns by number. If we wanted to get the first
>column from our data set, we would use zero":
>
>df = pandas.read_csv('./data/gapminder.tsv', sep='\t')
>>>> subset = df[[0]]
>>>> print(subset.head())
> country
>0 Afghanistan
>1 Afghanistan
>2 Afghanistan
>3 Afghanistan
>4 Afghanistan
>
>Data for the course:
>https://github.com/chendaniely/pandas_for_everyone.git
>
>"df[[0]]" is being described to the course student as selecting the first
>column of data. :-)

Well, I would say it makes a new dataframe with just the first column.

So:

df[ 0 ] # spaces for clarity

would (probably, need to check) return the Series for the first column.
versus:

df[ [0] ] # spaces for clarity

makes a new dataframe with only the first column.

A dataframe can be thought of as an array of Series (one per column).

Cheers,
Cameron Simpson <cs@cskk.id.au>


devel / comp.lang.python / Re: double bracket integer index in pandas; Is this a legal syntax

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor