Python histogram from unsorted data -


I'm trying to parse some data to create a histogram

In many columns of data But for me, only the columns below the relevant column are only for AB with the AB

I want to plot the histogram in the column of X <2. So histogram should be sorted and plotted:

  33 - 3 42 - 2   

(Even though 42 starts before, I First, I want to conspiracy 33).

I have lots of columns but it needs to be overcome by 'AB' character and search only those lines. Can anyone help?

Update: Data is in a CSV file and there are several columns.

EDIT: I now have data in a CSV file in this format.

From AP, 42

AP, 42

from AAP, 33

TOEP, 77

FromAP,

Toap, 42

fromAP, 42

from SEE, 42

TOAP, 33

TOAP, 42

FromAP, 42

SEE, 33

If I use code from dranxo,

  import pandas as pd import as the matplotlib.pyplot Plt df = pd.read_csv ('data.csv', sep = ',') df_useful = df [df ['addresses'] == 'fromAP'] df_useful.hist () plt.show ()   

I get the following error:

  Laptops @ Ubuntu: ~ / temp $. / Az /usr/lib/pymodules/python2.7/matplotlib/axes.py:8261: User Alert: 2d hist input should be nsamples x nvariables; It looks (size is 0 x 1) 'looks like (size is% dx% d)'% x.shape [:: - 1] traceback (most recent call final): File "./a. py ", in line 11, in & lt; Module & gt; Df_useful.hist () file "/usr/lib/python2.7/dist-packages/pandas/tools/plotting.py", line 2075, hist_frame ax.hist (data [color] .dropna (). Value, * * Kwds) file "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 8312, hist xmin = min (xmin, xi.min ()) file "/usr/lib/python2.7 / Dist-packages / numpy / core / _methods.py ", line 21, _min out = out, keepdims = keepdims) Value error: which is not the least recognized for the operation of lack of zero identity   

I have the pandus package, numpy, matplotlib installed. Thanks

Have you ever seen?

Here's how to parse the data and plot in some lines: import Import as a PD import matlotlib.pyplot plt df = pd Read_csv ('data.ssv', Sep = '') df_useful = df [df ['letters'] == 'AB'] df_useful.hist () plt.show ()

Enter image details here

Note: I The data is saved in the file by the name 'data'. Before calling '.ssv', pd.read_csv .

AB 42

CD-77

AB 33

AB 42

/ P>

AB 33

CD-54

Edit: To check that the problem is not with the data, Can run: import as import pandas np import np import matplotlib.pyplot plt df = pd.DataFrame (np.round (np.random.randn (10, 2)), column = ['a', 'b']) df.hist () plt.show ()

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -