plot data on graph using python [duplicate]
This question is an exact duplicate of:
draw data in graph using random forest python [on hold]
1 answer
how to plot this panda data set and show the destination id is x axis and prices is y axis on graph using python
destinationId = [2,5,4,4,5,7,8,7]
prices = [755, 800, 500, 400, 152, 444, 784, 954, 120]
df = pd.DataFrame([carriersID, destinationId, montheName, prices]).T
df.columns = ['carriersID', 'destinationId', 'departureDate', 'prices']
print(df)
+---+-------------+---------------+---------------+--------+
| | carriersID | destinationId | departureDate | prices |
+---+-------------+---------------+---------------+--------+
| 0 | 1.0 | 2.0 | 1.0 | 755.0 |
| 1 | 2.0 | 5.0 | 2.0 | 800.0 |
| 2 | 3.0 | 4.0 | 3.0 | 500.0 |
| 3 | 5.0 | 4.0 | 4.0 | 400.0 |
| 4 | 6.0 | 5.0 | 5.0 | 152.0 |
| 5 | 7.0 | 7.0 | 7.0 | 444.0 |
| 6 | 8.0 | 8.0 | 8.0 | 784.0 |
| 7 | 9.0 | 7.0 | NaN | 954.0 |
| 8 | NaN | NaN | NaN | 120.0 |
+---+-------------+---------------+---------------+--------+
python pandas matplotlib machine-learning
marked as duplicate by desertnaut, jpp
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 27 '18 at 15:25
This question was marked as an exact duplicate of an existing question.
add a comment |
This question is an exact duplicate of:
draw data in graph using random forest python [on hold]
1 answer
how to plot this panda data set and show the destination id is x axis and prices is y axis on graph using python
destinationId = [2,5,4,4,5,7,8,7]
prices = [755, 800, 500, 400, 152, 444, 784, 954, 120]
df = pd.DataFrame([carriersID, destinationId, montheName, prices]).T
df.columns = ['carriersID', 'destinationId', 'departureDate', 'prices']
print(df)
+---+-------------+---------------+---------------+--------+
| | carriersID | destinationId | departureDate | prices |
+---+-------------+---------------+---------------+--------+
| 0 | 1.0 | 2.0 | 1.0 | 755.0 |
| 1 | 2.0 | 5.0 | 2.0 | 800.0 |
| 2 | 3.0 | 4.0 | 3.0 | 500.0 |
| 3 | 5.0 | 4.0 | 4.0 | 400.0 |
| 4 | 6.0 | 5.0 | 5.0 | 152.0 |
| 5 | 7.0 | 7.0 | 7.0 | 444.0 |
| 6 | 8.0 | 8.0 | 8.0 | 784.0 |
| 7 | 9.0 | 7.0 | NaN | 954.0 |
| 8 | NaN | NaN | NaN | 120.0 |
+---+-------------+---------------+---------------+--------+
python pandas matplotlib machine-learning
marked as duplicate by desertnaut, jpp
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 27 '18 at 15:25
This question was marked as an exact duplicate of an existing question.
add a comment |
This question is an exact duplicate of:
draw data in graph using random forest python [on hold]
1 answer
how to plot this panda data set and show the destination id is x axis and prices is y axis on graph using python
destinationId = [2,5,4,4,5,7,8,7]
prices = [755, 800, 500, 400, 152, 444, 784, 954, 120]
df = pd.DataFrame([carriersID, destinationId, montheName, prices]).T
df.columns = ['carriersID', 'destinationId', 'departureDate', 'prices']
print(df)
+---+-------------+---------------+---------------+--------+
| | carriersID | destinationId | departureDate | prices |
+---+-------------+---------------+---------------+--------+
| 0 | 1.0 | 2.0 | 1.0 | 755.0 |
| 1 | 2.0 | 5.0 | 2.0 | 800.0 |
| 2 | 3.0 | 4.0 | 3.0 | 500.0 |
| 3 | 5.0 | 4.0 | 4.0 | 400.0 |
| 4 | 6.0 | 5.0 | 5.0 | 152.0 |
| 5 | 7.0 | 7.0 | 7.0 | 444.0 |
| 6 | 8.0 | 8.0 | 8.0 | 784.0 |
| 7 | 9.0 | 7.0 | NaN | 954.0 |
| 8 | NaN | NaN | NaN | 120.0 |
+---+-------------+---------------+---------------+--------+
python pandas matplotlib machine-learning
This question is an exact duplicate of:
draw data in graph using random forest python [on hold]
1 answer
how to plot this panda data set and show the destination id is x axis and prices is y axis on graph using python
destinationId = [2,5,4,4,5,7,8,7]
prices = [755, 800, 500, 400, 152, 444, 784, 954, 120]
df = pd.DataFrame([carriersID, destinationId, montheName, prices]).T
df.columns = ['carriersID', 'destinationId', 'departureDate', 'prices']
print(df)
+---+-------------+---------------+---------------+--------+
| | carriersID | destinationId | departureDate | prices |
+---+-------------+---------------+---------------+--------+
| 0 | 1.0 | 2.0 | 1.0 | 755.0 |
| 1 | 2.0 | 5.0 | 2.0 | 800.0 |
| 2 | 3.0 | 4.0 | 3.0 | 500.0 |
| 3 | 5.0 | 4.0 | 4.0 | 400.0 |
| 4 | 6.0 | 5.0 | 5.0 | 152.0 |
| 5 | 7.0 | 7.0 | 7.0 | 444.0 |
| 6 | 8.0 | 8.0 | 8.0 | 784.0 |
| 7 | 9.0 | 7.0 | NaN | 954.0 |
| 8 | NaN | NaN | NaN | 120.0 |
+---+-------------+---------------+---------------+--------+
This question is an exact duplicate of:
draw data in graph using random forest python [on hold]
1 answer
python pandas matplotlib machine-learning
python pandas matplotlib machine-learning
edited Dec 27 '18 at 17:30
dhilmathy
1,3991917
1,3991917
asked Dec 27 '18 at 14:46
user 123548
13
13
marked as duplicate by desertnaut, jpp
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 27 '18 at 15:25
This question was marked as an exact duplicate of an existing question.
marked as duplicate by desertnaut, jpp
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 27 '18 at 15:25
This question was marked as an exact duplicate of an existing question.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Have you tried the pandas plot
function? I assume that you want a Bar chart, but more options exist.
df.plot(x='destinationId', y='prices', kind='bar')
add a comment |
df = df.set_index(1)
Where 1
is a column number (destinationId
in that case).
Check documentation for more info:
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html
New contributor
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Have you tried the pandas plot
function? I assume that you want a Bar chart, but more options exist.
df.plot(x='destinationId', y='prices', kind='bar')
add a comment |
Have you tried the pandas plot
function? I assume that you want a Bar chart, but more options exist.
df.plot(x='destinationId', y='prices', kind='bar')
add a comment |
Have you tried the pandas plot
function? I assume that you want a Bar chart, but more options exist.
df.plot(x='destinationId', y='prices', kind='bar')
Have you tried the pandas plot
function? I assume that you want a Bar chart, but more options exist.
df.plot(x='destinationId', y='prices', kind='bar')
answered Dec 27 '18 at 14:50
Romain
6,14422136
6,14422136
add a comment |
add a comment |
df = df.set_index(1)
Where 1
is a column number (destinationId
in that case).
Check documentation for more info:
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html
New contributor
add a comment |
df = df.set_index(1)
Where 1
is a column number (destinationId
in that case).
Check documentation for more info:
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html
New contributor
add a comment |
df = df.set_index(1)
Where 1
is a column number (destinationId
in that case).
Check documentation for more info:
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html
New contributor
df = df.set_index(1)
Where 1
is a column number (destinationId
in that case).
Check documentation for more info:
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html
New contributor
New contributor
answered Dec 27 '18 at 14:58
Anonymous
1
1
New contributor
New contributor
add a comment |
add a comment |