Features | List | Tuple | Dictionary | Set | Series (pandas) | Dataframes (pandas) |
---|---|---|---|---|---|---|
Ideal for | Sequential, mutable data | Sequential, immutable data | Mapping data | Removing duplicates, set operations | Time series, single variable analysis | Multi-variable analysis, data manipulation |
Main Use case | Storing ordered collections | Immutable sequences | Key-value pairs | Unique elements | Single column data | Tabular data |
Data type | Any | Any | Any (for values) | Immutable types only | Homogeneous | Heterogeneous (by column) |
Ordered | Yes | Yes | Yes | No | Yes | Yes |
Mutable* | Yes | No | Yes | Yes | Yes | Yes |
Access by | Index | Index | Key | N/A | Index or label | Row/column index or label |
Allows duplicates | Yes | Yes | No | No | Yes | Yes |
* Refers to whether an object can be changed after it is created. Immutable objects provide a level of safety and predictability in certain scenarios, but mutable objects can be more memory-efficient for operations that require frequent modifications.