Skip to content

Commit

Permalink
Merge pull request #362 from data-8/updae_read_table
Browse files Browse the repository at this point in the history
Switch from pandas.read_table to pandas.read_csv, to avoid deprecation warnings.
  • Loading branch information
davidwagner authored Jun 11, 2019
2 parents 2765846 + 1a2347b commit b59803c
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pip install datascience

This project adheres to [Semantic Versioning](http://semver.org/).

### v0.11.3
Switch from pandas.read_table to pandas.read_csv, to avoid deprecation warnings. Shouldn't change the behavior of the library.

### v0.11.2
* `Table.append_column` now returns the table it is modifying.

Expand Down
2 changes: 1 addition & 1 deletion datascience/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def read_table(cls, filepath_or_buffer, *args, **vargs):
vargs['sep'] = ','
except AttributeError:
pass
df = pandas.read_table(filepath_or_buffer, *args, **vargs)
df = pandas.read_csv(filepath_or_buffer, *args, **vargs)
return cls.from_df(df)

def _with_columns(self, columns):
Expand Down
2 changes: 1 addition & 1 deletion datascience/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.11.2'
__version__ = '0.11.3'
8 changes: 8 additions & 0 deletions tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,3 +1640,11 @@ def test_url_parse():
with pytest.raises(ValueError):
url = 'https://data8.berkeley.edu/something/something/dark/side'
Table.read_table(url)

def test_read_table():
"""Test that Tables reads a csv file."""
assert isinstance(Table().read_table("tests/us-unemployment.csv"), Table)
assert isinstance(Table().read_table("tests/us-unemployment-copy"), Table)
assert isinstance(Table().read_table("tests/us-unemployment.txt"), Table)
assert isinstance(Table().read_table("https://raw.githubusercontent.com/data-8/textbook/gh-pages/data/deflategate.csv"), Table)

51 changes: 51 additions & 0 deletions tests/us-unemployment-copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
State,Unemployment
AL,7.1
AK,6.8
AZ,8.1
AR,7.2
CA,10.1
CO,7.7
CT,8.4
DE,7.1
FL,8.2
GA,8.8
HI,5.4
ID,6.6
IL,8.8
IN,8.4
IA,5.1
KS,5.6
KY,8.1
LA,5.9
ME,7.2
MD,6.8
MA,6.7
MI,9.1
MN,5.6
MS,9.1
MO,6.7
MT,5.8
NE,3.9
NV,10.3
NH,5.7
NJ,9.6
NM,6.8
NY,8.4
NC,9.4
ND,3.2
OH,6.9
OK,5.2
OR,8.5
PA,8
RI,10.1
SC,8.8
SD,4.4
TN,7.8
TX,6.4
UT,5.5
VT,5
VA,5.8
WA,7.8
WV,7.5
WI,6.8
WY,5.1
51 changes: 51 additions & 0 deletions tests/us-unemployment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
State Unemployment
AL 7.1
AK 6.8
AZ 8.1
AR 7.2
CA 10.1
CO 7.7
CT 8.4
DE 7.1
FL 8.2
GA 8.8
HI 5.4
ID 6.6
IL 8.8
IN 8.4
IA 5.1
KS 5.6
KY 8.1
LA 5.9
ME 7.2
MD 6.8
MA 6.7
MI 9.1
MN 5.6
MS 9.1
MO 6.7
MT 5.8
NE 3.9
NV 10.3
NH 5.7
NJ 9.6
NM 6.8
NY 8.4
NC 9.4
ND 3.2
OH 6.9
OK 5.2
OR 8.5
PA 8
RI 10.1
SC 8.8
SD 4.4
TN 7.8
TX 6.4
UT 5.5
VT 5
VA 5.8
WA 7.8
WV 7.5
WI 6.8
WY 5.1

0 comments on commit b59803c

Please sign in to comment.