0

I just started to code with Python.

I am doing some analysis on a database of papers extracted from the Scopus database. I downloaded the database in .csv and then performed some analyses and filtering on it. After the initial analyses I saved the file in .xlsx which is the current format of the database.
I am trying to obtain a graph showing how many times a journal is present in the database.
I have extracted the values using the value_counts() command and then I have stored these data into a table with two columns (Journal and Count):

journals_count = data['Source_title'].value_counts().reset_index()
journals_count.columns = ['Journal', 'Count']

                                          Journal Count
0     IEEE Transactions on Industrial Informatics 40
1                Expert Systems with Applications 37
2                                  Applied Energy 20
3   International Journal of Production Economics 13
4                            Energy and Buildings 11
5                            Information Sciences 11
6 International Journal of Information Management 10
7                        Decision Support Systems 9
8 International Journal of Advanced Manufacturing 9 
9    International Journal of Production Research 8
10       European Journal of Operational Research 7

Now I would like to create a bar chart from this table with the Journal name on the x-axis and the Count value on the y-axis using the following code:

import matplotlib.pyplot as plt
%matplotlib inline
plt.plot(journals_count['Journal'], journals_count['Count'])

The problem is that I obtain the following error:

ValueError: could not convert string to float: 'Service Industries Journal'

'Service Industries Journal' is the last journal with the Count value equal to 1.

How could I plot this into Python?

Georgy
  • 12,464
  • 7
  • 65
  • 73
sroverto
  • 57
  • 7
  • 1
    If you are working with pandas then you can do it directly from pandas' methods; you can have a look how to do it in https://pandas.pydata.org/pandas-docs/stable/visualization.html – Juan Apr 20 '18 at 13:02

1 Answers1

0

I think you should enumerate the String values in journals_count['Journal'] into [1, 2, 3, ...]. After that map those values to your journals_count['Journal'] with xticks.

x = np.arange(len(journals_count['Journal']))
plt.xticks(x, journals_count['Journal'])
plt.plot(x, journals_count['Count'])
plt.show()
galmeriol
  • 461
  • 4
  • 14