Message Boards Message Boards

0
|
1210 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:
GROUPS:

Conditional column data replacement

Posted 1 year ago

How do I conditionally replace every float in the "muncipalityname" column with corresponding row data from the "tollcompany" column?

enter image description here

POSTED BY: Tobi Babatunde
6 Replies
Posted 1 year ago

Maybe something like this:

data /. {head___, m_String, _?NumberQ} :> {head, m, m}
POSTED BY: Eric Rimbey

This did the job, thanks a lot!

POSTED BY: Tobi Babatunde
Posted 1 year ago

Is this a Mathematica question? It looks like a spreadsheet question. Are you importing the spreadsheet to a Dataset, and does your question apply to the Dataset?

POSTED BY: Eric Rimbey

It is a Mathematica question, I am only using a spreadsheet to show what the data looks like, it was a CSV file separated by ";" so I imported it and applied a field separator, the challenge now is is some of the data from the last 3 columns overlapped, I'm trying to correct that by replacing the floats with the corresponding name from the preceding column.

POSTED BY: Tobi Babatunde
Posted 1 year ago

Okay, then it'd be easier if you gave us the representation you have in Mathematica.

POSTED BY: Eric Rimbey
data = {{"toll_cordon", "toll_cordon_section", "toll_company", 
  "municipality_name"}, {"Oslo", "Osloringen", "Oslo", 
  59.92}, {"Oslo", "Osloringen", "Fjellinjen", "Oslo"}, {"Oslo", 
  "Osloringen", "Oslo", 59.9221}, {"Oslo", "Osloringen", "Fjellinjen",
   "Oslo"}, {"Oslo", "Osloringen", "Oslo", 59.9315}, {"Oslo", 
  "Osloringen", "Fjellinjen", "Oslo"}, {"Oslo", "Osloringen", 
  "Fjellinjen", "Oslo"}, {"Oslo", "Osloringen", "Oslo", 
  59.9467}, {"Oslo", "Osloringen", "Oslo", 59.9401}, {"Oslo", 
  "Osloringen", "Fjellinjen", "Oslo"}, {"Oslo", "Osloringen", "Oslo", 
  59.9236}, {"Oslo", "Osloringen", "Fjellinjen", "Oslo"}, {"Oslo", 
  "Osloringen", "Oslo", 59.8791}, {"Oslo", "Osloringen", "Oslo", 
  59.8782}, {"Oslo", "Osloringen", "Fjellinjen", "Oslo"}, {"Oslo", 
  "Osloringen", "Fjellinjen", "Oslo"}, {"Oslo", "Osloringen", 
  "Fjellinjen", "Oslo"}, {"Oslo", "Osloringen", "Oslo", 
  59.8849}, {"Oslo", "Osloringen", "Oslo", 59.9509}}
POSTED BY: Tobi Babatunde
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract