mars-project / mars-project/mars
[BUG] Result inconsistent when intermediate results executed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The same DataFrame expression outputs different results. The only difference is that the first piece of code does not execute intermediately while the second executes.
**To Reproduce**
```python
import numpy as np
import pandas as pd
import mars.dataframe as md
import mars.tensor as mt
rs = np.random.RandomState(0)
raw_df = rs.rand(20, 10)
raw_df = pd.DataFrame(
np.where(raw_df > 0.4, raw_df, np.nan), columns=list("ABCDEFGHIJ")
)
raw_df2 = rs.rand(20, 10)
raw_df2 = pd.DataFrame(
np.where(raw_df2 > 0.4, raw_df2, np.nan), columns=list("ACDEGHIJKL")
)
df = md.DataFrame(raw_df, chunk_size=4)
df2 = md.DataFrame(raw_df2, chunk_size=6)
joined = md.merge(
df.index.to_frame(), df2.index.to_frame(), how="outer", left_index=True, right_index=True
)
df, df2 = df.reindex(joined.index), df2.reindex(joined.index)
nna_df = df.notna().astype(np.float_)
nna_df2 = df2.notna().astype(np.float_)
df, df2 = df.fillna(0), df2.fillna(0)
print(df.mul(nna_df2, axis=0).sum(axis=0).execute().fetch())
"""
prints
A 0.0
B 0.0
C 0.0
D 0.0
E 0.0
F 0.0
G 0.0
H 0.0
I 0.0
J 0.0
K 0.0
L 0.0
dtype: float64
"""
df.execute()
nna_df2.execute()
print(df.mul(nna_df2, axis=0).sum(axis=0).execute().fetch())
"""
prints
A 4.392781
B 0.000000
C 5.063856
D 5.276695
E 4.752212
F 0.000000
G 5.451037
H 4.206434
I 6.948446
J 2.303648
K 0.000000
L 0.000000
dtype: float64
"""
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Python reproduction, focusing on md.merge, DataFrame.reindex, DataFrame.execute, and fetch. Compare the two execution paths and trace why intermediate execution changes the result. Done means both paths produce the same DataFrame output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, pandas, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100