- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19.2k
Deprecate Aliases as orient Argument in DataFrame.to_dict #32516
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
Changes from 13 commits
3cf3ed9
              2e783e0
              dcc4c2e
              b755897
              dc1207b
              1a78f3c
              0e5a874
              43d702c
              e52a3b2
              ad5afa5
              f161803
              a2edef1
              e069a60
              7075467
              fb7de33
              4164a87
              c598b32
              7b9e90f
              3d6efa5
              6e117ee
              36f9561
              a17765e
              9619403
              fa43f06
              d0bc7dc
              9e3daba
              d1b9c50
              9557349
              dcc9d43
              228b71e
              beb1f32
              4173ce6
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -1399,11 +1399,14 @@ def to_dict(self, orient="dict", into=dict): | |
| ) | ||
| # GH16122 | ||
| into_c = com.standardize_mapping(into) | ||
| if orient.lower().startswith("d"): | ||
| orient = orient.lower() | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 1328 above might also need a change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would think so - are you interested in submitting a PR to update the documentation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs to be removed in a future PR. Check below, there is a   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, so to confirm, in the future any code like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, it should | ||
| if orient == "dict": | ||
|         
                  jreback marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| return into_c((k, v.to_dict(into)) for k, v in self.items()) | ||
| elif orient.lower().startswith("l"): | ||
|  | ||
| elif orient == "list": | ||
| return into_c((k, v.tolist()) for k, v in self.items()) | ||
| elif orient.lower().startswith("sp"): | ||
|  | ||
| elif orient == "split": | ||
| return into_c( | ||
| ( | ||
| ("index", self.index.tolist()), | ||
|  | @@ -1417,9 +1420,11 @@ def to_dict(self, orient="dict", into=dict): | |
| ), | ||
| ) | ||
| ) | ||
| elif orient.lower().startswith("s"): | ||
|  | ||
| elif orient == "series": | ||
| return into_c((k, com.maybe_box_datetimelike(v)) for k, v in self.items()) | ||
| elif orient.lower().startswith("r"): | ||
|  | ||
| elif orient == "records": | ||
| columns = self.columns.tolist() | ||
| rows = ( | ||
| dict(zip(columns, row)) | ||
|  | @@ -1429,13 +1434,15 @@ def to_dict(self, orient="dict", into=dict): | |
| into_c((k, com.maybe_box_datetimelike(v)) for k, v in row.items()) | ||
| for row in rows | ||
| ] | ||
| elif orient.lower().startswith("i"): | ||
|  | ||
| elif orient == "index": | ||
| if not self.index.is_unique: | ||
| raise ValueError("DataFrame index must be unique for orient='index'.") | ||
| return into_c( | ||
| (t[0], dict(zip(self.columns, t[1:]))) | ||
| for t in self.itertuples(name=None) | ||
| ) | ||
|  | ||
| else: | ||
| raise ValueError(f"orient '{orient}' not understood") | ||
|  | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.