
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create Series in Python and Convert to JSON File
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}
Advertisements