I have a dataset which has a column called "PS_I". I cannot change this because I imported the column from an existing csv.
I would like to add another column. Such as:
data = data[All, Append[#,"newPSI" -> #PS_I * 3]&]
But that doesn't work due to underscore being a predefined character.
How do I get around this?
EDIT: Here's an example.
This is one column with such an index:
data = Dataset[ {<|"PS_I" -> 1|>,
<|"PS_I" -> 2|>,
<|"PS_I" -> 3|>,
<|"PS_I" -> 4|>,
<|"PS_I" -> 5|>,
<|"PS_I" -> 6|>,
<|"PS_I" -> 7|>}]
And I want to create a new column with some operation on the values of the PS_I column. Kind of what this answer suggested: How can I add a column into a existing Dataset?
The underscore does not allow for these type of operations, and I would like to know how to deal with this problem.
EDIT2:
Here's how to reproduce the problem, now with input from JasonB:
1) Create a csv with these contents: http://pastebin.com/eYUaW2bV
2) Run
data = SemanticImport["<pathtofolder>/example.csv"];
3) Try to append with
data = data[All, Append[#,"newPSI" -> #"PS_I" * 3]&]
#"PS_I"– Jason B. Nov 21 '16 at 20:14data[All, Append[#, "newPSI" -> #"PS_I"*3] &]with your definition ofdataand it works: http://i.stack.imgur.com/3Yhs2.png – Jason B. Nov 21 '16 at 20:22data = SemanticImport["pathToCSV.csv"];
With a csv with the same values?
– triplebig Nov 21 '16 at 20:24SemanticImporton your data file, whether downloading first or just grabbing it from pastebin, it labels the first column as "PS_V PS_I" and the second column as "column2". See here. That's why you can't access a column called#"PS_I"– Jason B. Nov 21 '16 at 20:41SemanticImportis getting confused by the leading tab on the header line and is treating the whole line as the name of the first column. If you delete that leading tab, then all is well. Incidentally, the file is TSV not CSV. – WReach Nov 21 '16 at 20:42