I am doing some exercises with datasets like so:
List with many dictionaries
users = [
{"id": 0, "name": "Ashley"},
{"id": 1, "name": "Ben"},
{"id": 2, "name": "Conrad"},
{"id": 3, "name": "Doug"},
{"id": 4, "name": "Evin"},
{"id": 5, "name": "Florian"},
{"id": 6, "name": "Gerald"}
]
Dictionary with few lists
users2 = {
"id": [0, 1, 2, 3, 4, 5, 6],
"name": ["Ashley", "Ben", "Conrad", "Doug","Evin", "Florian", "Gerald"]
}
Pandas dataframes
import pandas as pd
pd_users = pd.DataFrame(users)
pd_users2 = pd.DataFrame(users2)
print pd_users == pd_users2
Questions:
- Should I structure the datasets like users or like users2?
- Are there performance differences?
- Is one more readable than the other?
- Is there a standard I should follow?
- I usually convert these to pandas dataframes. When I do that, both versions are identical... right?
- The output is true for each element so it doesn't matter if I work with panda df's right?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…