Dictionary has keys and values mixed up
See original GitHub issueWhen opening a dictionary of dataframes from the Variable explorer, the sizes and values do not match the actual data. Specifically, when I start sorting the keys, one can see that the sizes are not sorted correctly:
I get this problem even before “sorting” the dictionary, because when opening the dictionary the keys by default are displayed alphabetically and not in the actual insertion order.
However, I do not have this problem with dicts of small dfs. E.g., sorting this one works perfectly fine:
directors = {}
directors["A"] = pd.DataFrame({"A": "joe","A2": "biden"}, index=[0])
directors["B"] = pd.DataFrame({"B": "don","B2": "trump"}, index=[0])
directors["C"] = pd.DataFrame({"C": "anderson","C2": "cooper"}, index=[0])
directors["D"] = pd.DataFrame({"D": "katie","D2": "hobbs"}, index=[0])
- Spyder version: 4.1.5
- Python version: 3.7.7 64-bit
- Qt version: 5.12.8
- PyQt version: 5.12.3
- Operating System name/version: Windows 10
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Python program to create a dictionary with mixed keys, and ...
Here, we are going to learn how to create a dictionary with mixed keys, and print the keys, values & key-value pairs in...
Read more >Python: how does a dict with mixed key type work?
The keys of the dictionary are the entries of the set, and values of the dictionary just hold a single value for each...
Read more >Python - Extract Key's value from Mixed Dictionaries List
In this, we iterate for each dictionary inside list, and check for key in it, if present the required value is returned. Python3....
Read more >working with dictionaries in Python - ZetCode
Python dictionary is a container of key-value pairs. It is mutable and can contain mixed types. A dictionary is an unordered collection.
Read more >Restrictions on Dictionary Keys and Values - Real Python
First, a given key can appear in a dictionary only once. Duplicate keys are not allowed. A dictionary maps each key to a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @ccordoba12, thanks for responding so quickly! I see GitHub has already linked my pull request, so I guess I’m only commenting here to show my appreciation 👍
I’m currently using 4.2.0 and see a similar issue.
Steps to reproduce:
var = {'a_len=4': [1,2,3,4], 'b_len=8': [1,2,3,4,5,6,7,8], 'c_len=5': [1,2,3,4,5]}
As the problem only ocurred when sorting in the reverse direction, I quickly tracked it down to the line https://github.com/spyder-ide/spyder/blob/436290ba71bb16c5928676467a358b70f4f38c10/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L288 It is missing a keyword argument “reverse=reverse”. (Verified by editing my local files.)
I could make a pull request with this change. Would branch 4.x be the right place to put it?