Repository: streamlit/streamlit

Issue:
Using new experimental_data_editor throws TypeError
### Checklist

- [X] I have searched the [existing issues](https://github.com/streamlit/streamlit/issues) for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.

### Summary

After updating to version 1.19.0 and testing the new experimental_data_editor functionality by utilising the example code (and dataframe) in the documentation, I get:

TypeError: data type 'complex256' not understood

Of note I get the same error if I insert "st.write(df.dtypes)" before the line using experimental_data_editor.

Lukas thought it might be a dependency issue.



### Reproducible Code Example

```Python
import streamlit as st
import pandas as pd
    
df = pd.DataFrame(
        [
            {"command": "st.selectbox", "rating": 4, "is_widget": True},
            {"command": "st.balloons", "rating": 5, "is_widget": False},
            {"command": "st.time_input", "rating": 3, "is_widget": True},
        ]
)
edited_df = st.experimental_data_editor(df)
```


### Steps To Reproduce

Run the above code using streamlit run filename.py

### Expected Behavior

Expect to see the new experimental data editor

### Current Behavior

Error Message:

TypeError: data type 'complex256' not understood
Traceback:
xxx
File "xxx\streamlit\runtime\metrics_util.py", line 311, in wrapped_func
    result = non_optional_func(*args, **kwargs)
File "xxx\streamlit\elements\data_editor.py", line 592, in experimental_data_editor
    _apply_data_specific_configs(columns_config, data_df, data_format)
File "xxx\streamlit\elements\data_editor.py", line 376, in _apply_data_specific_configs
    if type_util.is_colum_type_arrow_incompatible(column_data):
File "xxx\streamlit\type_util.py", line 653, in is_colum_type_arrow_incompatible
    if column.dtype in [

### Is this a regression?

- [ ] Yes, this used to work in a previous version.

### Debug info

- Streamlit version: 1.19.0
- Python version: 3.7.13
- Operating System: Windows
- Browser: Chrome
- Virtual environment: MiniConda

- pandas: 1.1.5
- numpy: 1.21.6


### Additional Information

_No response_

### Are you willing to submit a PR?

- [ ] Yes, I am willing to submit a PR!


Discussion:

Resolving patch:
diff --git a/lib/streamlit/type_util.py b/lib/streamlit/type_util.py
--- a/lib/streamlit/type_util.py
+++ b/lib/streamlit/type_util.py
@@ -650,13 +650,11 @@ def pyarrow_table_to_bytes(table: pa.Table) -> bytes:
 
 def is_colum_type_arrow_incompatible(column: Union[Series, Index]) -> bool:
     """Return True if the column type is known to cause issues during Arrow conversion."""
-    if column.dtype in [
-        # timedelta64[ns] is supported by pyarrow but not in the Arrow JS:
+    if column.dtype.kind in [
+        # timedelta is supported by pyarrow but not in the Arrow JS:
         # https://github.com/streamlit/streamlit/issues/4489
-        "timedelta64[ns]",
-        "complex64",
-        "complex128",
-        "complex256",
+        "m",  # timedelta64[ns]
+        "c",  # complex64, complex128, complex256
     ]:
         return True
 


Test patch:
diff --git a/lib/tests/streamlit/type_util_test.py b/lib/tests/streamlit/type_util_test.py
--- a/lib/tests/streamlit/type_util_test.py
+++ b/lib/tests/streamlit/type_util_test.py
@@ -180,7 +180,8 @@ def test_convert_anything_to_df_supports_key_value_dicts(self):
     @parameterized.expand(
         [
             # Complex numbers:
-            (pd.Series([1 + 2j, 3 + 4j, 5 + 6 * 1j]), True),
+            (pd.Series([1 + 2j, 3 + 4j, 5 + 6 * 1j], dtype=np.complex64), True),
+            (pd.Series([1 + 2j, 3 + 4j, 5 + 6 * 1j], dtype=np.complex128), True),
             # Timedelta:
             (pd.Series([pd.Timedelta("1 days"), pd.Timedelta("2 days")]), True),
             # Mixed-integer types: