Comments (5)
Thanks for the report. Can you simplify this? Produce the DataFrame that goes into the groupby explicitly (i.e. remove the use of assign, sort_values, and query), and show the result you get.
from pandas.
df.groupby.first
has a skipna
argument that defaults to True
https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.first.html
Try setting that to False
.
In [190]: pd.DataFrame({'a': [1, 1, 2, 2], 'b': [np.nan, '2', '3', '4']}).groupby('a').first(skipna=False)
Out[190]:
b
a
1 NaN
2 3
In [191]: pd.DataFrame({'a': [1, 1, 2, 2], 'b': [np.nan, '2', '3', '4']}).groupby('a').first()
Out[191]:
b
a
1 2
2 3
from pandas.
Okay, my bad.
Made sure, that I have > 2.2.1 on all machines.
skipna, did help. Problem was, when I search for the documentation for first. I find the DataFrame.first and not the DataFrameGroupBy.first.
I think, this is a problem, but something different.
from pandas.
@sehHeiden - it's not clear to me if your issue is resolved or not. If it isn't resolved, can you post a reproducible example (see my previous comment).
from pandas.
Solved.
@asishm s solution works. Tested with 2.2.2, but does not work with 2.2.0 as it does not have the skipna parameter.
Optional wish: Do link GroupBy.first in the DataFrame.first documentation.
from pandas.
Related Issues (20)
- BUG: Groupby transformation (cumsum) output dtype depends on whether NA is among group labels HOT 9
- DOC: Docstrings missing from .py files in Sphinxext docs folder HOT 7
- BUG: Lookup by datetime in timestamp index does not work HOT 1
- DOC: Insufficient Project Background Information HOT 2
- BUG: pd.Index.Intersection fails with multiple data frames HOT 3
- BUG: pd.concat fails with large index values when using ArrowDtype
- BUG: Importing Pandas takes 30 seconds HOT 1
- DOC: Enhance the docstrings to provide more detailed explanations for the functions and their parameters in Common.py HOT 3
- Reduce redundancy: Common.py HOT 1
- ENH: add `atol`, `rtol` and `check_exact` to the Object.compare() method HOT 1
- BUG: Warning when compiling pandas/_libs/algos.c
- BUG: to_excel() cuts off list of values when creating Excel file HOT 4
- BUG: matplotlib 3.9.0 has issue with pandas when using `subplots=True` on `df.plot.scatter()` HOT 1
- BUG: pandas read_xml with iterparse and stylesheets silently ignores stylesheets
- BUG: Inconsistent types for groupby group names HOT 2
- BUG: to_datetime behaves differently depending of the format of the string provided HOT 1
- BUG: pandas.errors.LossySetitemError when backtesting Freqtrade HOT 1
- BUG: from_dict() hidden (correct) behavior not aligned with documentation and typing: accepts and processes lists of dicts HOT 2
- ENH: Flip order of bar chart bars for multi-column data HOT 7
- Test Suite: Expand Test Coverage for `script\tests\test_inconsistent_namespace.py HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandas.