-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Problem with to_dict('records') in 0.24 #25050
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
Comments
The problem seems to be related to complicated headers: This here works pandas 0.23.0
0 California 289 This same code does not work in pandas 0.24.0 : pandas 0.24.0
0 California 289 However after fixing the headers the pandas 0.24.0 version also works: pandas 0.24.0
0 California 289 |
I encountered with the same error. |
Hi,
Running the following code in Pandas 0.24, the column names of the later object are completely wrong. May be that when the column name contains a : the to_dict('records') method is bugged?
CODE:
import pandas as pd
df = pd.read_csv("C:\running-example.csv")
print(df.columns)
print(df.to_dict().keys())
print(df.to_dict('records'))
OUTPUT:
Index(['Unnamed: 0', 'Activity', 'Costs', 'Resource', 'case:concept:name',
'case:creator', 'concept:name', 'org:resource', 'time:timestamp'],
dtype='object')
dict_keys(['Unnamed: 0', 'Activity', 'Costs', 'Resource', 'case:concept:name', 'case:creator', 'concept:name', 'org:resource', 'time:timestamp'])
[{'_0': 0, 'Activity': 'register request', 'Costs': 50, 'Resource': 'Pete', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'register request', '_7': 'Pete', '_8': '2010-12-30 14:32:00+01:00'}, {'_0': 1, 'Activity': 'examine casually', 'Costs': 400, 'Resource': 'Mike', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'examine casually', '_7': 'Mike', '_8': '2010-12-30 15:06:00+01:00'}, {'_0': 2, 'Activity': 'check ticket', 'Costs': 100, 'Resource': 'Ellen', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'check ticket', '_7': 'Ellen', '_8': '2010-12-30 16:34:00+01:00'}, {'_0': 3, 'Activity': 'decide', 'Costs': 200, 'Resource': 'Sara', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'decide', '_7': 'Sara', '_8': '2011-01-06 09:18:00+01:00'}, {'_0': 4, 'Activity': 'reinitiate request', 'Costs': 200, 'Resource': 'Sara', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'reinitiate request', '_7': 'Sara', '_8': '2011-01-06 12:18:00+01:00'}, {'_0': 5, 'Activity': 'examine thoroughly', 'Costs': 400, 'Resource': 'Sean', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'examine thoroughly', '_7': 'Sean', '_8': '2011-01-06 13:06:00+01:00'}, {'_0': 6, 'Activity': 'check ticket', 'Costs': 100, 'Resource': 'Pete', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'check ticket', '_7': 'Pete', '_8': '2011-01-08 11:43:00+01:00'}, {'_0': 7, 'Activity': 'decide', 'Costs': 200, 'Resource': 'Sara', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'decide', '_7': 'Sara', '_8': '2011-01-09 09:55:00+01:00'}, {'_0': 8, 'Activity': 'pay compensation', 'Costs': 200, 'Resource': 'Ellen', '_4': 3, '_5': 'Fluxicon Nitro', '_6': 'pay compensation', '_7': 'Ellen', '_8': '2011-01-15 10:45:00+01:00'}, {'_0': 9, 'Activity': 'register request', 'Costs': 50, 'Resource': 'Mike', '_4': 2, '_5': 'Fluxicon Nitro', '_6': 'register request', '_7': 'Mike', '_8': '2010-12-30 11:32:00+01:00'}, {'_0': 10, 'Activity': 'check ticket', 'Costs': 100, 'Resource': 'Mike', '_4': 2, '_5': 'Fluxicon Nitro', '_6': 'check ticket', '_7': 'Mike', '_8': '2010-12-30 12:12:00+01:00'}, {'_0': 11, 'Activity': 'examine casually', 'Costs': 400, 'Resource': 'Sean', '_4': 2, '_5': 'Fluxicon Nitro', '_6': 'examine casually', '_7': 'Sean', '_8': '2010-12-30 14:16:00+
................
The text was updated successfully, but these errors were encountered: