Skip to content

Commit

Permalink
Make Stata.data_label method a property
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankarlos committed Apr 4, 2019
1 parent df41bdb commit df8beec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1731,11 +1731,12 @@ def _do_convert_categoricals(self, data, value_label_dict, lbllist,
data = DataFrame.from_dict(OrderedDict(cat_converted_data))
return data

@property
def data_label(self):
"""
Return data label of Stata file.
"""
return self.data_label
return self._data_label

def variable_labels(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/test_stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def test_read_dta18(self):
'Floats': 'float data'}
tm.assert_dict_equal(vl, vl_expected)

assert rdr._data_label == 'This is a Ünicode data label'
assert rdr.data_label == 'This is a Ünicode data label'

def test_read_write_dta5(self):
original = DataFrame([(np.nan, np.nan, np.nan, np.nan, np.nan)],
Expand Down Expand Up @@ -499,7 +499,7 @@ def test_timestamp_and_label(self, version):

with StataReader(path) as reader:
assert reader.time_stamp == '29 Feb 2000 14:21'
assert reader._data_label == data_label
assert reader.data_label == data_label

@pytest.mark.parametrize('version', [114, 117])
def test_invalid_timestamp(self, version):
Expand Down

0 comments on commit df8beec

Please sign in to comment.