Skip to content

Table Schema with MultiIndex includes unnescessary field #16203

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
TomAugspurger opened this issue May 2, 2017 · 1 comment
Closed

Table Schema with MultiIndex includes unnescessary field #16203

TomAugspurger opened this issue May 2, 2017 · 1 comment
Labels
IO JSON read_json, to_json, json_normalize Output-Formatting __repr__ of pandas objects, to_string

Comments

@TomAugspurger
Copy link
Contributor

In [11]: df = pd.DataFrame(np.random.randn(4, 4),
    ...:                 columns=pd.MultiIndex.from_product([('A', 'B'),
    ...:                                                  ('a', 'b')]))
    ...: df
    ...:
Out[11]:
          A                   B
          a         b         a         b
0  0.483942 -0.888943 -0.501563  1.688760
1  0.943328  0.487903 -0.310336  0.602214
2  0.261042 -1.753800  0.000682  1.439406
3 -0.571016 -0.763698  2.441181  0.109586

In [12]: build_table_schema(df.T)
Out[12]:
{'fields': [{'name': 'level_0', 'type': 'string'},
  {'name': 'level_1', 'type': 'string'},
  {'name': 'values', 'type': 'number'},  # this is wrong
  {'name': 1, 'type': 'number'},
  {'name': 2, 'type': 'number'},
  {'name': 3, 'type': 'number'}],
 'pandas_version': '0.20.0',
 'primaryKey': FrozenList(['level_0', 'level_1'])}

Will try to get to this now.

@TomAugspurger TomAugspurger added IO JSON read_json, to_json, json_normalize Output-Formatting __repr__ of pandas objects, to_string labels May 2, 2017
@TomAugspurger
Copy link
Contributor Author

Oh, it's not that values shouldn't be there, it's that we treat 0 as false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO JSON read_json, to_json, json_normalize Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

1 participant