Calling methods on invalid types
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Lies zunächst die verknüpfte Diskussion, Issue #11 und Issue #6, und vergleiche dann die gezeigten Reduktionsfälle von DataFrame und Series. Das Issue nennt keine Implementierungsdateien oder Tests; für den Abschluss wäre eine vereinbarte Richtlinie für ungültige Dtypes und ein konsistentes Verhalten über die Operationen hinweg erforderlich.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
This is a follow up of the discussions in:
- https://github.com/pydata-apis/dataframe-api/issues/6#issuecomment-639754182
- #11 (question:
pandas has parameters (bool_only, numeric_only) to let only apply the operation over columns of certain types only. Do we want it?)
See this example:
>>> df[['name', 'population']].mean()
population 2.729748e+07
dtype: float64
Even if the name column is selected, it is being ignored, since the mean of a string columns does not make sense. As opposed to raising an exception.
Many reductions implement a parameter to let control this behavior:
df[['name', 'population']].mean(numeric_only=False)
TypeError: could not convert string to float:
If we consider more methods to be applied directly over a dataframe, for example:
>>> df[['first_'name', 'last_name']].str.lower()
We may end up with a huge amount of string_only, bool_only, numeric_only parameters. All meaning something similar, but IMO adding a decent amount of complexity, and being difficult to keep the behavior consistent.
My preference would be to always raise, but being a software engineer I'm biased, and I guess many users may want this "magic".
So, I guess implementing an option, for example: pandas.options.mode.invalid_dtype {raise or skip} could make more sense.
The main problem with this approach is probably that it's not as easy to define the behavior for each operation:
(df.mean(numeric_only=True)
.mean(numeric_only=False))
Personally, I don't see this as an issue. IMO, the behavior depends more on the user than on the operation. I'd say for production code, having to be explicit, and selecting the columns to operate with, makes more sense. While in a notebook, avoiding exceptions with this sort of "magic" seems to be more useful.
I guess for Series/1-column DataFrame (see #6) it always makes sense to raise an exception.
Thoughts?
- Vorherrschende Sprache
- Python
- Sterne
- 106
- Forks
- 22
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus data-apis/dataframe-api
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
data-apis/dataframe-api#363 · 1 Kommentar · 8 Reaktionen ·
-
API design
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
data-apis/dataframe-api#356 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
data-apis/dataframe-api#355 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
data-apis/dataframe-api#352 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
data-apis/dataframe-api#351 ·
Alle Issues in data-apis/dataframe-api
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
aws/sagemaker-python-sdk#6554 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
huggingface/diffusers#15170 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] LLM conflict check ignores MNEMOSYNE_LLM_MAX_TOKENS, so reasoning models return empty repliesOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
mnemosyne-oss/mnemosyne#1325 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement meshtastic-2.8
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
pskillen/meshflow-api#459 ·