How do I compare Python data sizes?

Asked 6 days ago, Updated 6 days ago, 1 views

When comparing data sizes in Python I compared it using functions such as size, len, and shape Can you tell me exactly how large this data is on the memory? MB, GB...

in addition The string in the JSON structure Convert to dict-list form (type=list) When converting to Dataframe through Pandas

Which one has the largest data size among String, List, and Dataframe?

python

2022-09-20 15:14

1 Answers

sys.getsizeof(object[, default])

Returns the size of the object in bytes. An object can be of any type. All embedded objects return the correct results, but third-party extensions cannot guarantee this because they are implementation-specific.

Includes only memory consumption that contributed directly to the object; does not consider the memory consumption of the object it refers to.

If given, if the object does not provide a means to query the size, it returns default. Otherwise, TypeError occurs.

getsizeof() invokes the object's sizeof method and adds an additional garbage collector overhead when the object is managed by the garbage collector.

For an example of recursive use of getsizeof() to find the size of the container and all its contents, see Recursive size of recipe.

Extract: https://docs.python.org/ko/3/library/sys.html


2022-09-20 15:14

If you have any answers or tips


© 2022 pinfo. All rights reserved.