Skip to content

ENH: Add uint and bool support in to_stata #7726

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

Closed
wants to merge 1 commit into from

Conversation

bashtage
Copy link
Contributor

Added support for uint (uint8, uint16 and uint32, but not uint64) and bool
datatypes in to_stata.
closes #7097
closes #7365

@jreback jreback added this to the 0.15.0 milestone Jul 10, 2014
@jreback
Copy link
Contributor

jreback commented Jul 10, 2014

we'll just call you mr. stata from now on :)

can you move the release note to 0.15.0.txt (0.14.1 coming tomorrow), so too late for that

@bashtage
Copy link
Contributor Author

I think this is ready.

upcast if needed. int64 data is not usable in Stata, and so it is
downcast to int32 whenever the value are in the int32 range, and
sidecast to float64 when larger than this range. If the int64 values
are outside of the range of those perfectly representable as float64 values,
a warning is raised.

bool columns are cast to int8. uint colums are converted to int of the same
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a note to the io.rst stata section explaining on dtype conversion works with the various types?

@bashtage
Copy link
Contributor Author

@jreback I added some docs.

@@ -3504,6 +3504,28 @@ into a .dta file. The format version of this file is always 115 (Stata 12).
df = DataFrame(randn(10, 2), columns=list('AB'))
df.to_stata('stata.dta')

Stata data files have limited data type support and only strings with 244 or
fewer characters, ``int8``, ``int16``, ``int32`` and ``float64`` can written
to a valid dta file. Additionally, certain values are reserved tp represent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to represent

@jreback
Copy link
Contributor

jreback commented Jul 15, 2014

minor edits, otherwise looks good.

@@ -3504,6 +3504,28 @@ into a .dta file. The format version of this file is always 115 (Stata 12).
df = DataFrame(randn(10, 2), columns=list('AB'))
df.to_stata('stata.dta')

*Stata* data files have limited data type support; only strings with 244 or
fewer characters, ``int8``, ``int16``, ``int32`` and ``float64`` can written
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be written. maybe say .dta file

Added support for uint (uint8, uint16 and uint32, but not uint64) and bool
datatypes in to_stata.   Added an explanation of supported data types in io.rst.
closes pandas-dev#7097 and closes pandas-dev#7365
@jreback
Copy link
Contributor

jreback commented Jul 16, 2014

thanks @bashtage continued awesome stata support is great!

@jreback
Copy link
Contributor

jreback commented Jul 16, 2014

merged via 7745d72

@jreback jreback closed this Jul 16, 2014
@bashtage bashtage deleted the stata-uint-bool branch July 16, 2014 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions IO Stata read_stata, to_stata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

df.to_stata does not support uint16 df.to_stata doesn't handle boolean columns
2 participants