"""The code worked with a dict, and used groupby to retrieve subdicts of lists of indexes based on length.
Then I had to apply a process on this, and I popped on the lists of indexes built by groupby through a loop.
But this morning I ran the code, it worked, then I updated Pandas to 19.0.0.1 and it started to bug with the TypeError as Int64Index has no .pop() indeed."""
dictoflists={0:[0],1:[1,3],2:[2,3],3:[3,4],4:[4,5,6],5: [3,0,1,6,7,8]}
tested={0:[0,1],1:[8,1,3],2:[2,3],3:[3,4],4:[9,9,9],5: [3,0,1,6,7,8], 6:[0,0,0,1]}
transform_df=pd.DataFrame(dictoflists,dtype=object,index=dictoflists.keys(),
columns=['Sequence'])
transform_df['length']=[len(list_i) for list_i in dictoflists.values()]
transform_df2=transform_df.groupby('length', sort=False)
for key,value in transform_df2.groups.items():
group_index=value
while True:
ref=tested[group_index.pop()]
I easily circumvented this by turning value into a list with 'group_index=list(value)' but I want to give this feedback as I don't know if the change is intentional or not, as I could not find a reference about it in the release notes.
Edit: updated to include reference for variables...
Comment From: jreback
pls give a copy-pastable example (you post is has undefined variables)
Comment From: BLMeltdown
Done
Comment From: chris-b1
@BLMeltdown - it's kind of buried, but this change was intentional and is noted at the end of this doc section - before .groups
could return either an ndarray
or list
, now it always returns an Index
. Your workaround is fine, or you could also call .tolist()
on the index.
http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#other-api-changes