Comments (5)
Change c
to self
.
I just kind of tossed this code off, I thought maybe you knew how to code in Python a bit and could fix the issues and get it working for yourself. Adding this feature properly will probably require more polish (including documentation and a test) once it's working, and it's not a priority on our roadmap.
Kondo'ed for now.
from visidata.
What is the error in one of the cells? You can see it with z Ctrl+E
.
from visidata.
Traceback (most recent call last):
File "/Users/user/miniconda3/lib/python3.11/site-packages/visidata/wrappers.py", line 105, in wrapply
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/miniconda3/lib/python3.11/site-packages/visidata/column.py", line 340, in getValue
return self.calcValue(row)
^^^^^^^^^^^^^^^^^^^
File "/Users/user/.visidatarc", line 27, in calcValue
prevval = self.prevCol.getTypedValue(row)
^^^^^^^^^^^^
AttributeError: 'DiffPreviousColumn' object has no attribute 'prevCol'
from visidata.
Change prevCol
to sourceCol
(or vice versa).
from visidata.
I changed the code and now I got this error:
Traceback (most recent call last):
File "/Users/user/miniconda3/lib/python3.11/site-packages/visidata/wrappers.py", line 105, in wrapply
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/miniconda3/lib/python3.11/site-packages/visidata/column.py", line 340, in getValue
return self.calcValue(row)
^^^^^^^^^^^^^^^^^^^
File "/Users/user/.visidatarc", line 28, in calcValue
curval = c.getTypedValue(row)
^
NameError: name 'c' is not defined
my current code is:
class DiffPreviousColumn(Column):
def calcValue(self, row):
prevval = self.sourceCol.getTypedValue(row)
curval = c.getTypedValue(row)
#return (curval-prevval)/prevval
return 1
@Sheet.api
def diff_cols(sheet):
for c in vd.numericCols(sheet.visibleCols):
newcol = DiffPreviousColumn(c.name + 'diff', type=float, sourceCol=c)
sheet.addColumn(newcol, index=sheet.columns.index(c))
c.hide()
Sheet.addCommand('', 'diff-cols', 'diff_cols()')
from visidata.
Related Issues (20)
- Cannot open xpt files with the latest xport dependency version HOT 2
- AttributeError: `AttrColumn` object has no attribute `column_letter` HOT 1
- The expression used for custom columns using `=` is evaluated repeatedly HOT 2
- [eml] Add an alias for mhtml file type that maps to eml
- [eml] Traceback when using the x command to extract entries without a filename HOT 1
- Can't disable mouse HOT 2
- vd v3.0.2 performance regression on Android HOT 1
- [Windows] Error: use_default_colors() returned ERR HOT 1
- system crash opening large (compressed) file
- unable to edit nested json value
- shell-command-on-cell HOT 1
- vdsql: edit cell, copy as sql, dump data...
- `history` parameter of input() is appears ignored HOT 1
- Support Decimal type HOT 1
- vsdql related errors on load and `&`
- Can't open any file HOT 2
- Scientific notation shown for column with large number even when type is string HOT 2
- [texttables] incorrect 'tabulate' module installed with brew HOT 6
- Autodetect file delimiters by scanning the first ten lines HOT 1
- Some issues during first time testing vdsql HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from visidata.