Hi,
I am at the following code in the course, but it gives error when using tm.makeTimeDataFrame() and also the pandas.util.testing is deprecated. I have the latest version of pandas (2.2.0) installed. What should be the replacement syntax for these to work.
Can you please help?
import pandas.util.testing as tm; tm.N = 3
import numpy as np
import pandas as pd
def unpivot(frame):
N, K = frame.shape
data = {‘value’ : frame.values.ravel(‘F’),
‘variable’ : np.asarray(frame.columns).repeat(N),
‘date’ : np.tile(np.asarray(frame.index), K)}
return pd.DataFrame(data, columns=[‘date’, ‘variable’, ‘value’])
df = unpivot(tm.makeTimeDataFrame())
print(df)