question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Must specify axis=0 or 1

See original GitHub issue
from ppca import PPCA
ppca = PPCA()
ppca.fit(X)
<ipython-input-36-931cb5915c29> in <module>()
----> 1 ppca.fit(X)

/usr/local/lib/python2.7/dist-packages/ppca/_ppca.pyc in fit(self, data, d, tol, min_obs, verbose)
     26 
     27         self.raw = data
---> 28         self.raw[np.isinf(self.raw)] = np.max(self.raw[np.isfinite(self.raw)])
     29 
     30         valid_series = np.sum(~np.isnan(self.raw), axis=0) >= min_obs

/usr/local/lib/python2.7/dist-packages/pandas/core/frame.pyc in __setitem__(self, key, value)
   2514             self._setitem_array(key, value)
   2515         elif isinstance(key, DataFrame):
-> 2516             self._setitem_frame(key, value)
   2517         else:
   2518             # set column

/usr/local/lib/python2.7/dist-packages/pandas/core/frame.pyc in _setitem_frame(self, key, value)
   2552         self._check_inplace_setting(value)
   2553         self._check_setitem_copy()
-> 2554         self._where(-key, value, inplace=True)
   2555 
   2556     def _ensure_valid_index(self, value):

/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in _where(self, cond, other, inplace, axis, level, errors, try_cast)
   5902 
   5903                 _, other = self.align(other, join='left', axis=axis,
-> 5904                                       level=level, fill_value=np.nan)
   5905 
   5906                 # if we are NOT aligned, raise as we cannot where index

/usr/local/lib/python2.7/dist-packages/pandas/core/frame.pyc in align(self, other, join, axis, level, copy, fill_value, method, limit, fill_axis, broadcast_axis)
   2917                                             method=method, limit=limit,
   2918                                             fill_axis=fill_axis,
-> 2919                                             broadcast_axis=broadcast_axis)
   2920 
   2921     @Appender(_shared_docs['reindex'] % _shared_doc_kwargs)

/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in align(self, other, join, axis, level, copy, fill_value, method, limit, fill_axis, broadcast_axis)
   5728                                       copy=copy, fill_value=fill_value,
   5729                                       method=method, limit=limit,
-> 5730                                       fill_axis=fill_axis)
   5731         else:  # pragma: no cover
   5732             raise TypeError('unsupported type: %s' % type(other))

/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in _align_series(self, other, join, axis, level, copy, fill_value, method, limit, fill_axis)
   5827                     fdata = fdata.reindex_indexer(join_index, lidx, axis=0)
   5828             else:
-> 5829                 raise ValueError('Must specify axis=0 or 1')
   5830 
   5831             if copy and fdata is self._data:

ValueError: Must specify axis=0 or 1```

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
mhorsley30896commented, Apr 11, 2020

So if you pass a numpy array into .fit it seems to work

from ppca import PPCA
X = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
ppca = PPCA()
ppca.fit(X.values)
2reactions
pavel-razgovorovcommented, May 23, 2020

@mhorsley30896 is correct: you must pass a numpy array instead of a pandas DataFrame. You can convert a dataframe with the to_numpy method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Boolean indexing a DataFrame in pandas an replacing the ...
It seems as bug. I think boolean indexing is internally convert to where . So you can use df.where(df>0, s, axis=0 ...
Read more >
How to Use axis=0 and axis=1 in Pandas? - GeeksforGeeks
In pandas axis = 0 refers to horizontal axis or rows and axis = 1 refers to vertical axis or columns.
Read more >
pyspark.pandas.series - Apache Spark
Series([1, 2, 3]) >>> psser.axes [Int64Index([0, 1, 2], dtype='int64')] ... is None): raise ValueError("Must specify a fillna 'value' or 'method' parameter.
Read more >
dask.dataframe.multi - Dask documentation
1. Align the partitions of all inputs to be the same. ... _is_broadcastable(df)] if len(dfs) == 0: raise ValueError("dfs contains no DataFrame and...
Read more >
Python for Machine Learning: Pandas Axis Explained
A DataFrame object has two axes: “axis 0” and “axis 1”. “axis 0” represents rows and “axis 1” represents columns. Now it's clear...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found