0

I have a pandas data frame wit the following properties:

Name: df_name,

Concerned Column: col1

If I want to plot a column, I can execute the following code in python shell(>>>) or ipython notebook.

>>>df_name['col1'].plot(kind='bar')

However, I want to use the same function in a script and execute from command line, the plot doesn't appear.

The script I want to write looks like the following:

import pandas as pd
.
.
.
df_name=pd.read_csv('filename')

# Printing bar chart of 'col1'

df_name['col1'].plot(kind='bar')

Any Ideas how to make it execute from a script?

munnahbaba
  • 231
  • 1
  • 3
  • 10

1 Answers1

0

I think, you need to import matplotlib.pyplot and to use show method like in example.

import pandas as pd
import matplotlib.pyplot as plt

df_name=pd.DataFrame([1,2,3])
df_name[0].plot(kind='bar')

plt.show()
MrFairWall
  • 158
  • 1
  • 2
  • 10