List with many dictionaries VS dictionary with few lists?

Learn, what if we use list with many dictionaries and what if we use dictionary with few lists?
Submitted by Pranit Sharma, on November 25, 2022

Pandas is a special tool that allows us to perform complex manipulations of data effectively and efficiently. Inside pandas, we mostly deal with a dataset in the form of DataFrame. DataFrames are 2-dimensional data structures in pandas. DataFrames consist of rows, columns, and data.

Here we are doing some exercises with datasets, we have a list with many dictionaries with contains some data also have a dictionary with a few list we need to identify:

  • Which data set is more appropriate to use
  • What is the performance difference between the two data sets
  • Is anyone dataset more readable than the other


  • By comparing a list with many dictionaries and a dictionary with few lists we represent column-oriented data sets versus row-oriented data sets.
  • If we talk about the performance it depends on the type of operations, we perform with the data, for example, Row-based data set is natural if we only access any row while in the case of using the cash or using search operations column-oriented databases are of much better use.
  • As far as the complexity of the datasets is concerned Pandas does convert both of the examples to the same format but the conversion is itself more expensive for the row-oriented structure.
  • Hence even after the expensive conversion for row-oriented structure both of the data sets are in a readable format.
  • At last, if we conclude which data structure should we use then it is suggested to start with the data structure that keeps the code sensible and optimize only when we know our use cases and have a measurable performance issue.

Python Pandas Programs »

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.