Skip to main content

All Questions

279 votes
8 answers
594k views

Add x and y labels to a pandas plot

Suppose I have the following code that plots something very simple using pandas: import pandas as pd values = [[1, 2], [2, 5]] df2 = pd.DataFrame(values, columns=['Type A', 'Type B'], ...
Everaldo Aguiar's user avatar
163 votes
4 answers
235k views

Annotate bars with values on Pandas bar plots

I was looking for a way to annotate my bars in a Pandas bar plot with the rounded numerical values from my DataFrame. >>> df=pd.DataFrame({'A':np.random.rand(2),'B':np.random.rand(2)},index=[...
leroygr's user avatar
  • 2,519
125 votes
5 answers
516k views

How to plot two columns of a pandas data frame using points

I have a pandas dataframe and would like to plot values from one column versus the values from another column. Fortunately, there is plot method associated with the dataframes that seems to do what I ...
Roman's user avatar
  • 132k
121 votes
3 answers
136k views

Pandas plot() without a legend

Using the pandas library in python and using .plot() on a dataframe, how do I display the plot without a legend?
Bilal Syed Hussain's user avatar
91 votes
3 answers
177k views

making matplotlib scatter plots from dataframes in Python's pandas

What is the best way to make a series of scatter plots using matplotlib from a pandas dataframe in Python? For example, if I have a dataframe df that has some columns of interest, I find myself ...
user avatar
57 votes
2 answers
165k views

Plot multiple columns of pandas DataFrame using Seaborn

suppose I have DataFrame with columns ['X_Axis','col_2','col_3',...,'col_n',] I need to plot the first column on X-Axis and rest on Y-Axis. FYI : all the values have been grouped according to X-Axis, ...
Rakmo's user avatar
  • 1,992
47 votes
3 answers
174k views

Xticks by pandas plot, rename with the string

I have this df: df = pd.DataFrame({'A': [1, 2, 3], 'B': [2, 3, 5], 'C': ['name 1', 'name 2', 'name 3']}) A B C 0 1 2 name 1 1 2 3 name 2 2 3 5 name 3 What is it the correct way to ...
Guforu's user avatar
  • 4,023
46 votes
3 answers
187k views

Plot a bar plot from a Pandas DataFrame

Assuming I have a DataFrame that looks like this: Hour V1 V2 A1 A2 0 15 13 25 37 1 26 52 21 45 2 18 45 45 25 3 65 38 98 14 I'm trying to create a bar plot to compare ...
Alfonso 's user avatar
36 votes
2 answers
78k views

Plot Pandas DataFrame as Bar and Line on the same one chart

I am trying to plot a chart with the 1st and 2nd columns of data as bars and then a line overlay for the 3rd column of data. I have tried the following code but this creates 2 separate charts but I ...
tfayyaz's user avatar
  • 756
32 votes
2 answers
107k views

How to surface plot/3d plot from dataframe

I am new to pandas and matplotlib. I couldn't get the exact reference to plot my DataFrame which has the following schema: schema = StructType([ StructField("x", IntegerType(), True), ...
mohan's user avatar
  • 1,530
29 votes
2 answers
89k views

Plot pandas dates in matplotlib

I have a fixed-width data file containing dates, but when I try to plot the data the dates are not displayed properly on the x-axis. My files looks like 2014-07-10 11:49:14.377102 45 2014-07-10 ...
Gerhard's user avatar
  • 2,045
29 votes
3 answers
139k views

How to set Dataframe Column value as X-axis labels

Say I have data in following format: Region Men Women City1 10 5 City2 50 89 When I load it in Dataframe and plot graph, it shows index as X-axis labels instead of Region name. How do I ...
Volatil3's user avatar
  • 15k
28 votes
4 answers
121k views

plot multiple pandas dataframes in one graph

I have created 6 different dataframes that eliminate the outliers of their own original data frames. Now, I'm trying to plot all of the dataframes that eliminate the outliers on the same graph. This ...
eliza.b's user avatar
  • 477
27 votes
4 answers
66k views

Display count on top of seaborn barplot [duplicate]

I have a dataframe that looks like: User A B C ABC 100 121 OPEN BCD 200 255 CLOSE BCD 500 134 OPEN DEF 600 125 CLOSE ABC 900 632 OPEN ...
Tjs01's user avatar
  • 477
22 votes
4 answers
37k views

Turn Pandas DataFrame of strings into histogram

Suppose I have a DataFrame of created like this: import pandas as pd s1 = pd.Series(['a', 'b', 'a', 'c', 'a', 'b']) s2 = pd.Series(['a', 'f', 'a', 'd', 'a', 'f', 'f']) d = pd.DataFrame({'s1': s1, 's2'...
amatsukawa's user avatar

15 30 50 per page
1
2 3 4 5
97