Skip to content

[BUG] zfill needs to align with python standard library in some cases  #11632

@galipremsagar

Description

@galipremsagar

Describe the bug
Similar to pandas-dev/pandas#20868

When the string column has data which has +/- prefix signs, they will aswell need to be moved during the zfill operation.

Steps/Code to reproduce bug

In [9]: import cudf

In [10]: s = cudf.Series(["-10", "+100", "+abc", "-/bcd"])

In [11]: s.str.zfill(10)
Out[11]: 
0    0000000-10
1    000000+100
2    000000+abc
3    00000-/bcd
dtype: object

In [12]: "-10".zfill(10)
Out[12]: '-000000010'

In [13]: "+100".zfill(10)
Out[13]: '+000000100'

In [14]: "+abc".zfill(10)
Out[14]: '+000000abc'

In [15]: "-/bcd".zfill(10)
Out[15]: '-00000/bcd'

In [16]: "a+b".zfill(10)
Out[16]: '0000000a+b'

In [17]: "100-".zfill(10)
Out[17]: '000000100-'

Expected behavior
Match python standard library behavior shown above for some special cases.

Environment overview (please complete the following information)

  • Environment location: [Bare-metal]
  • Method of cuDF install: [from source]

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinglibcudfAffects libcudf (C++/CUDA) code.stringsstrings issues (C++ and Python)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions