- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- Make a multiline plot from .CSV file in matplotlib
- Plot data from a .txt file using matplotlib
- Writing data from database to .csv file
- How to plot CSV data using Matplotlib and Pandas in Python?
- How to read data from *.CSV file using JavaScript?
- How to read data from .csv file in Java?
- Write data from/to a .csv file in java
- How to import csv file data from Github in R?
- How can we import data from .CSV file into MySQL table?
- How to extract data from a Matplotlib plot?
- How to read the data from a CSV file in Java?\n
- Python Pandas- Create multiple CSV files from existing CSV file
- Python Tkinter – How to export data from Entry Fields to a CSV file?
- How to plot data from multiple two-column text files with legends in Matplotlib?
- How to write data to .csv file in Java?

Advertisements