In the pandas Python library, we can use the DataFrame.plot.line() function to plot a line plot. The x parameter indicates the values on the x-axis and the y parameter indicates the values on the y-axis.
Let’s read the “flights” dataset. The dataset contains various information, such as year, number of passengers, etc. Let’s say we want to see a line plot between the number of passengers and the year. We can use the following Python code for that purpose:
import pandas from matplotlib import pyplot df = pandas.read_csv("flights.csv") df.plot.line(x="year", y="passengers") pyplot.savefig("flights-line.png")
Here, the DataFrame.plot.line() function plots a line plot. The x-axis indicates the years and the y-axis indicates the number of passengers.
The resulting line plot looks like the following:
Please note that when we do not specify the x parameter in the DataFrame.plot.line() function, the …






0 Comments