Monday 28 September 2020

How to convert a pandas dataframe into list of dictionaries ?

 Pandas is a high-level data manipulation tool commonly used in python. It is build on Numpy and the key data structure is DataFrame.

Here I am explaining a sample python program to convert a Pandas Dataframe into a list of dictionaries.

Program to convert Dataframe into list of dictionaries

In the below program, we are reading a csv file and loading it in pandas. You can configure the delimiter as per your requirement. The required_fields is an optional parameter that can be used to limit or select the required fields in the Dataframe from the csv. By default, it picks up all the fields in the file.

No comments:

Post a Comment

How to check the memory utilization of cluster nodes in a Kubernetes Cluster ?

 The memory and CPU utilization of a Kubernetes cluster can be checked by using the following command. kubectl top nodes The above command...