How do I select/copy info from web with Selenium and copy into IntelliJ to String? I'm using IntelliJ in Java. I am trying to use:

```
Navegador.getInstance().instanciaNavegador().findElement(By.xpath("//div[@id='cpf']/span[2]")).sendKeys(Keys.chord(Keys.CONTROL, "v"));

```
['https://Stackoverflow.com/questions/70713408', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/17934597/']
As [Kraigolas commented](https://stackoverflow.com/questions/70713383/for-loop-to-replace-value-in-one-dataframe-with-x-if-it-appears-in-another-dataf#comment125009505_70713383), you can easily do this without looping.

Check if elements are in another array with [`np.in1d`](https://numpy.org/doc/stable/reference/generated/numpy.in1d.html) and then map truth values to "X" and "Y":

```
import pandas as pd
import numpy as np

df1 = pd.DataFrame()
df1["col1"] = ["A", "B", "C", "D", "E"]
df2 = pd.DataFrame()
df2["col2"] = ["A", "C", "D"]

df1["col3"] = list(map(lambda x: "X" if x else "Y", np.in1d(df1.col1, df2.col2)))
print(df1)

```

Output:

```
  col1 col3
0    A    X
1    B    Y
2    C    X
3    D    X
4    E    Y

```
Given question with `dataframe` in title, variables `df1` and `df2` together with `col1` and `col2` probably is related to [pandas](/questions/tagged/pandas "show questions tagged 'pandas'") or [numpy](/questions/tagged/numpy "show questions tagged 'numpy'").

Without any further context provided, like code, we can only recommend vague options but not help with a specific solution.

Functions from Numpy, Pandas and Python built-in
------------------------------------------------

Following are some functions in the solution space:

1. element is in other collection: `numpy.in1d` (explained below), [`pandas.Series.isin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.isin.html), [`set & other` or `set.intersection()`](https://docs.python.org/3/library/stdtypes.html?highlight=set%20intersection#frozenset.intersection)
2. map boolean to string or character: `numpy.where` (explained below), [`pandas.Series.where`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.where.html), [`map`](https://docs.python.org/3/library/functions.html?highlight=map%20function#map)

### Value in 1-D array (exists / present / duplicated)

See numpy's [`in1d(ar1, ar2, assume_unique=False, invert=False)`](https://numpy.org/doc/stable/reference/generated/numpy.in1d.html) function:

> 
> Test whether each element of a 1-D array is also present in a second array.
> 
> 
> 

```py
import numpy as np

array_1 = np.array(['A', 'B', 'C'])
print(array_1)
# ['A' 'B' 'C']
array_1_elements_exist = np.in1d(array_1, ['C', 'D'])
print(array_1_elements_exist)
# [False False  True]

```

### Map to either X or Y (binary classification)

The mapping can be done using Python's built-in [`map(mapping_function, array_or_list)`](https://www.w3schools.com/python/ref_func_map.asp) as [answered by rikyeah](https://stackoverflow.com/a/70714258/5730279).

Or directly use numpy's [`where(condition, [x, y, ])`](https://numpy.org/doc/stable/reference/generated/numpy.where.html)

> 
> Return elements chosen from x or y depending on condition.
> 
> 
> 

to map binary values (in statistics this is called [*binary classification*](https://en.wikipedia.org/wiki/Statistical_classification#Binary_and_multiclass_classification)):

```py
import numpy as np

array_bool = np.array([True, False])
print(array_bool)
# array([ True, False])
array_str = np.where(array_bool, 'x', 'y')
print(array_bool)
# array(['x', 'y'], dtype='|S1')

```

Comparing two dataframes? (missing context for specific application)
--------------------------------------------------------------------

As the question hasn't shown a reproducible example yet, it is unclear how the combined functionality can be applied in context.

Until some [example](https://stackoverflow.com/help/minimal-reproducible-example) is provided in given question, the combination of both functions is left open.

Example applications of these functions to *pandas* are:

* [python: check if an numpy array contains any element of another array](https://stackoverflow.com/questions/36190533/python-check-if-an-numpy-array-contains-any-element-of-another-array/36190611#36190611)
* [Difference between pandas DataFrame 'where' and Numpy 'where'](https://stackoverflow.com/questions/44893381/difference-between-pandas-dataframe-where-and-numpy-where)
* [comparing two DataFrames, specific questions](https://stackoverflow.com/questions/44273037/comparing-two-dataframes-specific-questions)

Or in built-in Python:

* Python docs [intersection](https://docs.python.org/3/library/stdtypes.html?highlight=set%20intersection#frozenset.intersection)
* [using a conditional and lambda in map](https://stackoverflow.com/questions/31153002/using-a-conditional-and-lambda-in-map)