Skip to content

DOC: read_excel dtype parameter - str vs. object #16655

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
RobinFiveWords opened this issue Jun 10, 2017 · 1 comment · Fixed by #16658
Closed

DOC: read_excel dtype parameter - str vs. object #16655

RobinFiveWords opened this issue Jun 10, 2017 · 1 comment · Fixed by #16658
Labels
Milestone

Comments

@RobinFiveWords
Copy link

RobinFiveWords commented Jun 10, 2017

Code Sample, a copy-pastable example if possible

In [16]: import pandas as pd
    ...: import numpy as np
    ...: pd.DataFrame(['a', 1, np.nan]).to_excel('test.xlsx')
    ...: df_str = pd.read_excel('test.xlsx', dtype=str, names=['col_str'])
    ...: df_str['type_str'] = df_str.col_str.map(type)
    ...: df_obj = pd.read_excel('test.xlsx', dtype=object, names=['col_obj'])
    ...: df_obj['type_obj'] = df_obj.col_obj.map(type)
    ...: pd.concat([df_str, df_obj], axis=1)
    ...: 
Out[16]: 
  col_str       type_str col_obj         type_obj
0       a  <class 'str'>       a    <class 'str'>
1       1  <class 'str'>       1    <class 'int'>
2     nan  <class 'str'>     NaN  <class 'float'>

Problem description

I imagine read_excel's dtype parameter description should just read "Use object to preserve and not interpret dtype" and not "Use str or object".

@chris-b1
Copy link
Contributor

Yes - looks like I copied the read_csv docstring - PR welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants