Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: more distinguish name for widths arugment in read_fwf #34953

Open
erfannariman opened this issue Jun 23, 2020 · 1 comment
Open

ENH: more distinguish name for widths arugment in read_fwf #34953

erfannariman opened this issue Jun 23, 2020 · 1 comment
Assignees

Comments

@erfannariman
Copy link
Member

erfannariman commented Jun 23, 2020

Is your feature request related to a problem?

We ran into the problem that read_fwf uses widths as an argument to define contigious intervals. But because of **kwargs, it will also accept width and not throw a warning or error. In this case it will produce the wrong output, but without seeing the typo, it;s hard to find out what went wrong.

Describe the solution you'd like

Instead of the argument widths, use a more distinguish / informative name like fixed_widths. Or if changing the name is not preferable, we can throw a warning when a width is used in read_fwf instead of widths

API breaking implications

Not sure

Example with using the correct argument widths

d = StringIO("""
AA1234     aaaa     bbb
BB5678     cccc     ddd
CC9999     eeee     fff
""")

fixed_widths = [2, 4, 9, 8]
df = pd.read_fwf(d, widths=fixed_widths)

  Unnamed: 0  Unnamed: 1 Unnamed: 2 Unnamed: 3
0         AA        1234       aaaa        bbb
1         BB        5678       cccc        ddd
2         CC        9999       eeee        fff

Example using the wrong argument width:

d = StringIO("""
AA1234     aaaa     bbb
BB5678     cccc     ddd
CC9999     eeee     fff
""")

fixed_widths = [2, 4, 9, 8]
df = pd.read_fwf(d, width=fixed_widths)

  Unnamed: 0 Unnamed: 1 Unnamed: 2
0     AA1234       aaaa        bbb
1     BB5678       cccc        ddd
2     CC9999       eeee        fff
@erfannariman erfannariman added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 23, 2020
@erfannariman
Copy link
Member Author

take

@TomAugspurger TomAugspurger removed the Needs Triage Issue that has not been reviewed by a pandas team member label Sep 4, 2020
@mroeschke mroeschke added the IO Fixed Width read_fwf label Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants