I would like to know how to randomly select certain values from the attribute table.
Solved! Go to Solution.
A good discussion along with several good code examples can be found in previous threads, including https://community.esri.com/thread/121745 .
You can use the random module. Do you need random values in an attribute table? Or random rows?
I need to use it from python and not from ArcMap. Also, I just need to select the attributes and not assign random numbers to it.
The random module is a Python module.... Do you need to select random attributes from a single field? All fields? Some fields?
Please expand on your question. Give an example.
Ahhh, then generate your random integers, and use those in a search cursor to extract the values you need
Add a field to your table
Do a field calculation as described here
or you can substitute random.randint in place of random.random if you want integers.
a = random.randint(1, 100)
a
96
or even draw from a uniform distribution
u = int(random.uniform(0, 100))
u
54
or other types of distributions depending on your needs
A good discussion along with several good code examples can be found in previous threads, including https://community.esri.com/thread/121745 .
Thank you so much. This seems to work for me.