Comments (6)
The code seems to be taking an single list instead of numpy array below
from pandas.
original_list = func(y)
result = [[x] for x in original_list]
result = np.array(result)
This might help?
from pandas.
The problem exists in core\array_algos\datetimelike_accumulations.py
, _cum_func
:
result = func(y)
result[mask] = iNaT
Essentially, what this is doing is performing func
(np.cumsum
in this case) on your whole data array, and by default np.cumsum
computes the sum over a flattened array and returns it, but then when masking the NA values, it is expecting that the data array was in it's original shape and not flattened.
To fix this, you have to pass axis
as 0 to func
(again, np.cumsum
in this case), so that it performs the cumsum
along the given axis and not over the whole flattened array (it's the only func
with axis=None
by default, unlike cummin
and cummax
which have axis=0
by default and work properly)
from pandas.
@phofl @mroeschke any comment on this based on #41720. I found result is 1D while mask is an array. Thus I tried
flattened_mask = mask.flatten()
result[flattened_mask] = iNaT
but ended up in error at
block = self.blocks[self.blknos[i]]
values = block.iget(self.blklocs[i])
bp = BlockPlacement(slice(0, len(values)))
in managers.py
from pandas.
take
from pandas.
Thanks @Aloqeely for helping me understand this.
from pandas.
Related Issues (20)
- Make specific pandas dataframe column immuteable / not changeable HOT 4
- BUG: df.drop_duplicates fails if there is only a single row HOT 3
- Potential regression with PR "PERF: Eliminate circular references in accessor attributes (#58733)" HOT 1
- ENH: support parquet's enum type using Categorical when (de)serializing HOT 3
- ENH: generalize `__init__` on a `dict` to `abc.collections.Mapping` and `__getitem__` on a `list` to `abc.collections.Sequence` HOT 10
- ENH: Add a Series method which checks whether a Series is constant HOT 2
- BUG: df.agg with pd.NamedAgg axis=1 unsupported, but errors differently depending on contents of index HOT 1
- BUG: Segmentation Fault when importing Pandas in python 3.10.14 HOT 3
- BUG: df.agg with df with missing values results in IndexError HOT 3
- 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
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.