Question: I am using React Hook Form to set the value of `gender` autocomplete upon loading the data from API. But the autocomplete does not seem to set the data.
My main component looks like this:

```
// this function is used to set the default form values. for now, its just gender value
const setFormValues = () => {
       setValue("gender", {id: 'male', name: 'Male'})
    };

```

And in useEffect, I am running the above function whenever the data is done loading.

```
// prerequisites consists of many objects. gender is one of them
useEffect(() => {
        setFormValues();
    }, [prerequisites]);

```

Here is what the component looks like:

```
<Controller
        name={name}
        control={control}
        render={({field: {onChange}}) => (
          <Autocomplete
            onChange={(e, data) => onChange(data?.[onChangeAttribute])}
            options={options || []}
            getOptionLabel={(option) => option.name}
            isOptionEqualToValue={(option, value) => option.id === value.id}
            renderInput={(params) => <TextField {...params} placeholder="test" label="test"/>}
          />
        )}
      />

```

I then went on to the documentation which pointed me to [this](https://codesandbox.io/s/react-hook-form-controller-079xx?file=/src/MuiAutoComplete.js). Basically, I can pass a default value. I then went on to creating a state and setting that state from the `setFormValues()` function. The state was being set correctly. But when I pass it to the `defaultValue`, the value is not being set and instead shows me the error uncontrolled component being used as a controlled component and use it as a controlled component instead.

**What I am trying to do:**

The idea I had in mind was to set the default value which is coming from an API call on useEffect. Basically, the page is the 'edit' page and I want to show the current selection.

Answer: 
Idea with replace `NaN` to `NA`:

```
i = pd.MultiIndex.from_tuples([(0, 'o1'),
            (0, 'o2'),
            (0, 'o3'),
            (0, 'o4'),
            (0, 'o5'),
            (0, 'o6'),
            (0,  np.nan)])

df = pd.DataFrame({'a':0}, index=i)

df = df.rename(lambda x: 'NA' if pd.isna(x) else x, level=1)
print (df)
      a
0 o1  0
  o2  0
  o3  0
  o4  0
  o5  0
  o6  0
  NA  0

df.loc[(0, 'NA')]

```
One "bad solution", that is not really solving the underlying issue but provide a working solution, would be by converting the indices to strings (the `str` constructor is capable of amazing results here).

```
df.index = [str(idx) for idx in df.index]
df
Out 
(0, 'o1')        [0, 6]
(0, 'o2')        [1, 4]
(0, 'o3')        [2, 5]
(0, 'o4')    [8, 9, 12]
(0, 'o5')      [10, 13]
(0, 'o6')      [11, 14]
(0, nan)         [3, 7]
Name: x, dtype: object

df.index
Out
Index(['(0, 'o1')', '(0, 'o2')', '(0, 'o3')', '(0, 'o4')', '(0, 'o5')',
       '(0, 'o6')', '(0, nan)'],
      dtype='object')

xy_data[0].loc['(0, nan)']  # or
xy_data[0].loc[str((0, nan))]

```