Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: ValueError: shape mismatch: value array of shape...
Post: RE: ValueError: shape mismatch: value array of sha...

prediction[test_index] has shape (47, 1), while y_pred has shape (47,). Either define your prediction as 1D array (with np.zeros(y.shape[0]), or reshape your y_pred to (-1, 1).
zivoni Homework 2 23,723 Jul-10-2017, 11:57 AM
    Thread: Is it not possible to begin a for loop by 1 instead of 0
Post: RE: Is it not possible to begin a for loop by 1 in...

print M[x][1:] instead of M[x]. Actually you dont need to use range to remove first elements, you can use for row in M[1:]:    print(row[1:])
zivoni General Coding Help 7 5,232 Jul-08-2017, 07:03 AM
    Thread: Is it not possible to begin a for loop by 1 instead of 0
Post: RE: Is it not possible to begin a for loop by 1 in...

range accepts additional argument for starting value of sequence; you can use for i in range(1, 4):    print(i)to get Output:1 2 3
zivoni General Coding Help 7 5,232 Jul-08-2017, 06:26 AM
    Thread: Visualisation of gaps in time series data
Post: RE: Visualisation of gaps in time series data

I think that matplotlib try to put some small number of equidistantly spaced xticks (likely it depends on figure size and dpi) Its possible to use plt.xticks(list_of_x_values)to put xticks exactly w...
zivoni Homework 11 19,331 Jul-04-2017, 11:47 PM
    Thread: Excel analysis
Post: RE: Excel analysis

Iterating over rows in dataframe / numpy array is very often a bad idea, using pandas/numpy vectorized methods/functions is preferred (morever your i variable in your for loop has values only 0, 1, -1...
zivoni Data Science 3 4,021 Jul-04-2017, 09:52 PM
    Thread: Saving data from each row into separate txt
Post: RE: Saving data from each row into separate txt

I would guess it means that you have posted different "csv" file than you are actually processing... Your posted output was probably pandas dataframe output (with line numbers and fields unquoted and...
zivoni Data Science 7 11,358 Jul-04-2017, 09:12 PM
    Thread: Saving data from each row into separate txt
Post: RE: Saving data from each row into separate txt

It seems that your file contains either empty line or line containing only whitespaces. For such line split() returns empty list that leads to index out of a range error. You can save your split resu...
zivoni Data Science 7 11,358 Jul-04-2017, 08:43 AM
    Thread: np.arrange error - no attribute
Post: RE: np.arrange error - no attribute

Numpy has arange() function, not arrange(). Your examples should be like pp = np.arange(10)
zivoni Data Science 3 22,799 Jul-04-2017, 08:30 AM
    Thread: Visualisation of gaps in time series data
Post: RE: Visualisation of gaps in time series data

Values of missing should be True/False (special case of int), so basically you should be indexing with 1 or 0.
zivoni Homework 11 19,331 Jun-25-2017, 06:45 PM
    Thread: Visualisation of gaps in time series data
Post: RE: Visualisation of gaps in time series data

You can take care of irregular difference between timestamps by some truncating or "binning". Example on your timestamps (with fake values): Output:In [12]: tserie Out[12]: 2017-02-15 01:11:43.345424...
zivoni Homework 11 19,331 Jun-24-2017, 03:17 PM
    Thread: Visualisation of gaps in time series data
Post: RE: Visualisation of gaps in time series data

Data preprocessing in this case could be "filling" your timeseries such that it contains all "expected" timestamps. Simple example with daily data timeserie with single gap: Output:2017-05-01  10 2017...
zivoni Homework 11 19,331 Jun-23-2017, 09:59 PM
    Thread: speed up the "for loops"
Post: RE: speed up the "for loops"

You have there five nested for loops (probably each iterating over hundreths of values), so its no wonder that its slow. You should try to use numpy's features, for example your "binning" for loops ca...
zivoni Data Science 1 3,242 Jun-22-2017, 11:14 PM
    Thread: Need help reading in a binary file
Post: RE: Need help reading in a binary file

There is no array attribute defined in your class, so its correct that read.array raises AttributeError. As you have implemented __next__ and __iter__, it seems that proper way to use your class woul...
zivoni Data Science 2 3,953 Jun-22-2017, 10:04 AM
    Thread: Please, help to identify the mistake in the code
Post: RE: Please, help to identify the mistake in the co...

I would guess that problem is with while len(str1) < 10:       str1 = str1 + ""Your first str1 has length 2 and adding empty string does not increase it, so its infinite loop ... You probably wan...
zivoni General Coding Help 4 4,341 Jun-21-2017, 10:45 PM
    Thread: numpy.float64 and plot_date in matplotlib
Post: RE: numpy.float64 and plot_date in matplotlib

You do not convert your  date to matplotlib dates, value of your date is 20170608?, plt.plot_date takes it as number of days from 1.1.1, that is 55224 years, out of range of python datatetime. Moreve...
zivoni Data Science 1 5,748 Jun-21-2017, 10:23 PM
    Thread: output formating
Post: RE: output formating

You need to put correct number of spaces into your formation string, inside triple quotes there is no indentation, so you need to use something like      formation = '''  {} {}   {}  {}'''.format('R',...
zivoni General Coding Help 2 3,071 Jun-19-2017, 07:14 PM
    Thread: Removing data in a plot
Post: RE: Removing data in a plot

Sorry for late reply, there was misplaced ), it should be: skip_size = len(next(tscv.split(X))[0]) tcsv.split(X) returns generator object; calling next on it returns tuple of arrays containing indices...
zivoni Homework 3 3,803 Jun-19-2017, 06:31 PM
    Thread: Speeding up Twitter parser
Post: RE: Speeding up Twitter parser

You are probably dropping majority of your tweets, so it increases processing speed greatly. But putting if condition into your inner for loop is not so good, as you are checking exactly same conditio...
zivoni Data Science 3 3,686 Jun-19-2017, 06:01 PM
    Thread: Removing data in a plot
Post: RE: Removing data in a plot

Remove first elements from prediction (and y) with slicing when plotting. You can get length of first split either by directly computing it with skip_size = len(X) - 10 * (len(X) // (10 + 1))   # for ...
zivoni Homework 3 3,803 Jun-08-2017, 09:11 PM
    Thread: splitting or parsing control characters
Post: RE: splitting or parsing control characters

(May-26-2017, 06:59 PM)volcano63 Wrote: list(itertools.chain(*([s] if re.match('[\x01-\x20]', s)                      [''.join(g) for _, g in itertools.groupby(s)]                      for i, s i...
zivoni General Coding Help 19 11,118 May-26-2017, 07:27 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020