
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
Plot Data from CSV File with Matplotlib
To extract CSV file for specific columns to list in python, we can use Pandas read_csv() method.
Steps
- Make a list of columns that have to be extracted.
- Use read_csv() method to extract the CSV file data into a data frame.
- Print the exracted data.
- Plot the data frame using plot() method.
- To display the figure, use show() method.
Example
import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True columns = ["Name", "Marks"] df = pd.read_csv("input.csv", usecols=columns) print("Contents in csv file:
", df) plt.plot(df.Name, df.Marks) plt.show()
Output
Advertisements