Difference between dictionary and pandas series in Python

I have a requirement to store data in pairs of key values. I searched and found 2 paths in python:

  • default data dictionary.

    x = {'key':value} value = x['key'] 
  • pandas structure series.

     x = pandas.Series({'key':value}) value = x.key 

I want to know the difference between the two, except for the syntax.

+5
source share
1 answer

Always read documents first
But since you asked:

  • Dictionaries are one of the default data structures for python that allows you to store key: value pairs and offer some built-in methods for managing your data that you can read in documents ( here's a good summary to start the reading process).
  • Panda Series are one-dimensional ndarrays with axes that allow you to store array-like, dict, or scalar values ​​and are one of the numpy (scientific computing python library) built-in data structures.
    If you read the provided documents above (see Panda Series ), you will notice that they come with a huge number of methods and attributes completely different, for the most part, from the python word dictionary.

So this is not just a syntactic difference.

If you need to store multiple key:value pairs, a better and more elegant solution is to use the default dictionary. If you need to do some complex data manipulation of stored data, consider using the panda series.

+6
source

Source: https://habr.com/ru/post/1267186/


All Articles