Skip to content

Commit 78df0e3

Browse files
authored
Merge pull request #112 from DoubleML/m-doublemldata-str
Minor update of the str representation of `DoubleMLData` objects
2 parents 40f3e3c + 625922e commit 78df0e3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

doubleml/double_ml_data.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,18 @@ def __init__(self,
7676
self.set_x_d(self.d_cols[0])
7777

7878
def __str__(self):
79+
data_info = f'Outcome variable: {self.y_col}\n' \
80+
f'Treatment variable(s): {self.d_cols}\n' \
81+
f'Covariates: {self.x_cols}\n' \
82+
f'Instrument variable(s): {self.z_cols}\n' \
83+
f'No. Observations: {self.n_obs}\n'
7984
buf = io.StringIO()
8085
self.data.info(verbose=False, buf=buf)
81-
data_info = buf.getvalue()
82-
return f'=== DoubleMLData Object ===\n' \
83-
f'y_col: {self.y_col}\n' \
84-
f'd_cols: {self.d_cols}\n' \
85-
f'x_cols: {self.x_cols}\n' \
86-
f'z_cols: {self.z_cols}\n' \
87-
f'data:\n {data_info}'
86+
df_info = buf.getvalue()
87+
res = '================== DoubleMLData Object ==================\n' + \
88+
'\n------------------ Data summary ------------------\n' + data_info + \
89+
'\n------------------ DataFrame info ------------------\n' + df_info
90+
return res
8891

8992
@classmethod
9093
def from_arrays(cls, x, y, d, z=None, use_other_treat_as_covariate=True):

0 commit comments

Comments
 (0)