I was reshaping a DataFrame from wide to long format. However I get different results in two cases which should be identical - see below
import pandas as pd
import numpy as np
d_test = pd.DataFrame({"id": [1,2,3,5], "q1": [1,4,4,2], "q2": [4,np.nan,9,0]}, index=["a","b","c","d"])
# Gives an empty DataFrame as result
pd.wide_to_long(d_test,stubnames=["q"], suffix=r"\\d+", i="id", j="time")
# This works:
pd.wide_to_long(d_test,stubnames=["q"], i="id", j="time")
Note that both lines are the same: In the documentation you can see that the default value for the suffix argument is identical to the one I specified explicitly.
Can someone help me in understanding what went wrong here?