Hi all,
Would it be desirable to start allowing repr to follow this convention when an option is set for it, at least for simple arrays?
I built an integration test for some processing steps that take a fairly large input, clean it, train a model on it, and make predictions. The output is a dataframe that would be difficult to hand-enter into our test module. I was hoping to debug, copy the repr of `result`, and paste it into `expected = eval(<copied string>)`
Obviously, this didn't work, I think because pandas uses repr primarily to prepare output for display. Nevertheless, could it be possible, at least for simple arrays? I tried:
```
import pandas as pd
import numpy as np
temp = pd.DataFrame([[1,2],[3,4]], columns = ['A','B'], index = ['i1', 'i2'])
def optimistic_repr(df):
col_rep = repr(df.columns)
ind_rep = repr(df.index)
arr_rep_raw = repr(df.values)
replace = lambda m: 'numpy.'+m.group(1)
pattern = '(' + '(?!=)|'.join(numpy.__dict__.keys()) + '(?!=))'
arr_rep = re.sub(pattern, replace, arr_rep_raw)
return f"DataFrame({arr_rep}, columns={col_rep}, index={ind_rep})"
temp_repr = optimistic_repr(temp)
```
temp is
A B
i1 1 2
i2 3 4
the optimistic repr is:
"DataFrame(numpy.array([[1, 2],\n [3, 4]], dtype=numpy.int64), columns=Index(['A', 'B'], dtype='object'), index=Index(['i1', 'i2'], dtype='object'))"
Then the following code works as expected:
```
from pandas import DataFrame, Index
import numpy
eval(temp_repr)
```
More complicated objects would be trickier (doesn't even work for MultiIndex alone, let alone a DataFrame with a MultiIndex).
-Jake