Repository: plotly/plotly.py

Issue:
[Easy fix] plotly/express/_core.py:271 FutureWarning
Hi all,

I've got an online Jupyter notebook where I came across this error, but not sure how to fix and test this bug. I think it might be an easy fix:

```
/usr/local/lib/python3.9/dist-packages/plotly/express/_core.py:271: FutureWarning:

The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
```


Example code to reproduce the issue:
```
df = pd.DataFrame({'Weekday': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Thursday', 'Sunday'],
                   'Temperature': [10., 12., 14., 16., 12., 14., 16., 12., 14., 16.]})

temperatures = df.groupby('Weekday', as_index=False)['Temperature'].mean()
fig = px.line_polar(temperatures, r='Temperature', theta='Weekday', line_close=True)
fig.show()
```

The code that needs to be changed can be found here, on line 271:
https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/express/_core.py


I think the change will need to be:
`trace_data = trace_data.append(trace_data.iloc[0])` to `trace_data = pd.concat([trace_data, trace_data.iloc[0]])`





Discussion:
Hi @Getslow6. It appears this deprecation issue is being worked on in #4025, but it hasn't been merged yet

Resolving patch:
diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py
--- a/packages/python/plotly/plotly/express/_core.py
+++ b/packages/python/plotly/plotly/express/_core.py
@@ -268,7 +268,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
         fit information to be used for trendlines
     """
     if "line_close" in args and args["line_close"]:
-        trace_data = trace_data.append(trace_data.iloc[0])
+        trace_data = pd.concat([trace_data, trace_data.iloc[:1]])
     trace_patch = trace_spec.trace_patch.copy() or {}
     fit_results = None
     hover_header = ""


Test patch:
diff --git a/packages/python/plotly/test_requirements/requirements_39_pandas_2_optional.txt b/packages/python/plotly/test_requirements/requirements_39_pandas_2_optional.txt
--- a/packages/python/plotly/test_requirements/requirements_39_pandas_2_optional.txt
+++ b/packages/python/plotly/test_requirements/requirements_39_pandas_2_optional.txt
@@ -1,6 +1,6 @@
 requests==2.25.1
 tenacity==6.2.0
-pandas==2.0.0
+pandas==2.0.1
 numpy==1.20.3
 xarray==0.17.0
 statsmodels
diff --git a/test/percy/compare-pandas.py b/test/percy/compare-pandas.py
new file mode 100644
--- /dev/null
+++ b/test/percy/compare-pandas.py
@@ -0,0 +1,29 @@
+import difflib
+import json
+import os
+
+os.chdir(os.path.dirname(__file__))
+
+
+def clean_float(numstr):
+    # round numbers to 3 digits, to remove floating-point differences
+    return round(float(numstr), 3)
+
+
+def get_fig(html):
+    # strip off all the rest of the html and js
+    fig_str = html[html.index("[{", html.rindex("Plotly.newPlot(")) :]
+    fig_str = fig_str[: fig_str.index("}    ") + 1]
+    data, layout, config = json.loads(f"[{fig_str}]", parse_float=clean_float)
+    fig_dict = dict(data=data, layout=layout, config=config)
+    return json.dumps(fig_dict, indent=2).splitlines(keepends=True)
+
+
+for filename in os.listdir("pandas2"):
+    with open(filename, encoding="utf-8") as f1:
+        with open(os.path.join("pandas2", filename)) as f2:
+            fig1 = get_fig(f1.read())
+            fig2 = get_fig(f2.read())
+            if any(l1 != l2 for l1, l2 in zip(fig1, fig2)):
+                print("".join(difflib.unified_diff(fig1, fig2)))
+                raise ValueError(f"Pandas 1/2 difference in {filename}")