'How can I create a table where my inputs in one column spit out an assigned “code” for that text in another column?
I want to create a table that basically converts the text from one column into a specific code in another column. For example, I have a “rock type” column and a “geology code column”. If I type “SAND” into the rock type column then “401c” will appear in the geology code column.
Solution 1:[1]
In python, you can use a dictionary as following:
conversions = {...} # add conversions as (rock type: geology code)
Then, given some rock type rock_type, the corresponding geology code can be given by conversions[rock_type]. For example, using your example, you can insert converions["SAND"] = "401c". Then, later on, typing conversions["SAND"] will give 401c.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ChickenCoding123 |
