For setting indices, we need to set the x and y labels according to the following syntax:
set_xlabel('label name') set_ylabel('label name')
To work with pandas, we need to import pandas package first, below is the syntax:
import pandas as pd
Let us understand with the help of an example.
# Importing pandas package import pandas as pd # creating a dictionary d = { "Players":['Sachin','Ganguly','Dravid','Yuvraj','Dhoni','Kohli'], "Runs":[18426,11363,10889,8701,10773,12311] } # Now we will create DataFrame df = pd.DataFrame(d) # Viewing the DataFrame print("Original DataFrame:\n",df,"\n\n") plot = df.plot(lw=2, colormap='jet', marker='.', markersize=10, title='Players and their runs') plot.set_xlabel("X") plot.set_ylabel("Y") print(plot)
Output:
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Let us understand with the help of an example.
Output:

need an explanation for this answer? contact us directly to get an explanation for this answer