Solution
To solve this, we will follow the steps given below −
Define a series with a range of 1 to 10
Find the sum of all the values
Convert the series into JSON file format
Let us see the following implementation to get a better understanding.
Example
import pandas as pd data = pd.Series(range(1,11)) data['sum'] = data.sum() data = data.to_json() print(data)
Output
{"0":1,"1":2,"2":3,"3":4,"4":5,"5":6,"6":7,"7":8,"8":9,"9":10,"sum":55}