Skip to content

ffill, bfill are broken #21388

Closed
Closed
@VelizarVESSELINOV

Description

@VelizarVESSELINOV
"""Pandas bug."""
from io import StringIO

from pandas import read_csv

dtf = read_csv(StringIO('''G,M
G1253,
G1253,0
G1253,0
G1253,
G1253,
G1253,21.3
G1253,32.3
G1253,98.5
G1253,
G1253,121.9
G1253,
G1253,125.6
G1253,136.6
G1253,
G1253,144.2
G1253,
G1253,161.8
G1253,
G1253,180.1
G1253,180.1'''))

grp = dtf.groupby('G')

dtf['M1'] = grp.M.ffill()
dtf['M2'] = grp.M.fillna(method='ffill')

print(dtf[dtf.M1 != dtf.M2][['M1', 'M2']])

assert(dtf.M1.equals(dtf.M2))

Problem description

Expect ffill to be working and equal to fillna(ffill)

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Darwin
OS-release: 17.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.0
pytest: None
pip: 10.0.1
setuptools: 39.0.1
Cython: None
numpy: 1.14.2
scipy: 1.1.0
pyarrow: 0.9.0.post1
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.7.2
pytz: 2018.3
blosc: None
bottleneck: None
tables: 3.4.3
numexpr: 2.6.4
feather: None
matplotlib: 2.2.0
openpyxl: 2.5.0
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: None
lxml: 4.2.1
bs4: None
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Testingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions