AllenDowney / ThinkStats2

Text and supporting code for Think Stats, 2nd Edition
http://allendowney.github.io/ThinkStats2/
GNU General Public License v3.0
4.03k stars 11.31k forks source link

ThinkStats2 variable clipped (Row 2629) #36

Closed Lijantropique closed 2 years ago

Lijantropique commented 8 years ago

When reading the fixed length ASCII file, as the end value is lower than the start value the column gets clipped. To solve this I propose to read the ‘fstring’ value to determine the amount of positions, and add this value to the start point.

If this is solved, the note in the nsfg2 script (line 70) is no longer required.

AllenDowney commented 8 years ago

I will look into this as soon as I get a chance.

Thanks!

On Mon, Feb 8, 2016 at 2:15 PM, Oscar J. Delgado-Melo < notifications@github.com> wrote:

When reading the fixed length ASCII file, as the end value is lower than the start value the column gets clipped. To solve this I propose to read the ‘fstring’ value to determine the amount of positions, and add this value to the start point.

If this is solved, the note in the nsfg2 script (line 70) is no longer

required.

You can view, comment on, or merge this pull request online at:

https://github.com/AllenDowney/ThinkStats2/pull/36 Commit Summary

  • Update nsfg2.py
  • Update nsfg2.py
  • Update thinkstats2.py

File Changes

Patch Links:

— Reply to this email directly or view it on GitHub https://github.com/AllenDowney/ThinkStats2/pull/36.

Lijantropique commented 8 years ago

Alternatively, you could change the way you determine the 'end' column by doing:

variables['end']= variables.start + variables.fstring.apply(lambda x: int(x[1:-1]))

This should correct the bug as well. Please let me know if there is something I can help you with. Best!

AllenDowney commented 8 years ago

Thanks again!

On Tue, Feb 9, 2016 at 3:25 PM, Oscar J. Delgado-Melo < notifications@github.com> wrote:

Alternatively, you could change the way you determine the 'end' column by doing:

variables['end']= variables.start + variables.fstring.apply(lambda x: int(x[1:-1]))

This should correct the bug as well. Please let me know if there is something I can help you with. Best!

— Reply to this email directly or view it on GitHub https://github.com/AllenDowney/ThinkStats2/pull/36#issuecomment-182046360 .

AllenDowney commented 2 years ago

This should be resolved by 82f6384

Thanks!