Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5711
| From | Stefan Schwarzer <sschwarzer@sschwarzer.net> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] Verstaendnisproblem |
| Date | 2021-02-12 16:07 +0100 |
| Message-ID | <mailman.1112.1613142470.7193.python-de@python.org> (permalink) |
| References | <2763401.e9J7NaK4W3@host.fritz.box> <107543700.nniJfEyVGO@host.fritz.box> <bff5cf57-b57b-300b-17d8-5390cd8bb3da@web.de> <5436893.DvuYhMxLoT@host.fritz.box> <8c5a698d-6083-1244-f205-c843af42ef02@sschwarzer.net> |
On 2021-02-12 15:29, eilfh wrote: > Am Donnerstag, 11. Februar 2021, 18:48:23 CET schrieb Peter Otten: > Hallo, Peter > > danke für Deine Antwort. > > Das war das fehlende Puzzle in meinem Programm > >> >>> x >> >> 0 4 >> Name: B, dtype: int64 >> >> >>> type(x) >> >> <class 'pandas.core.series.Series'> >> >> >> kannst Du einfach entpacken >> >> >>> [y] = x >> >>> y >> >> 4 > > > um ehrlich zu sein, ich versteh's zwar nicht, > aber es läuft und erfüllte genau den Zweck Falls du `[y] = x` meinst, kann ich mir vorstellen, dass das komisch aussieht. Das ist sogenanntes implizites "Tuple unpacking", hier vielleicht eher "List unpacking". Du kannst das auch als `y = x[0]` schreiben; ich denke, das ist klarer. Die Schreibweise `[y] = x` hat allerdings wiederum den Vorteil, dass du eine Exception bekommst, wenn `x` mehr als ein zu "entpackendes" Element enthält, obwohl du das in deinem Code nicht erwartest. Viele Grüße Stefan
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] Verstaendnisproblem Stefan Schwarzer <sschwarzer@sschwarzer.net> - 2021-02-12 16:07 +0100
csiph-web