-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Steve Bentley
committed
Jun 15, 2017
1 parent
4c50169
commit b861313
Showing
8 changed files
with
180 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Gander provides DataFrames and Series to manipulate tabular data. It is based | ||
// on the excellent Python Pandas package (http://pandas.pydata.org/). | ||
// A DataFrame can be thought of as being similar to a spreadsheet, in that it holds | ||
// rows and columns of data. | ||
// | ||
// Data is loaded into a DataFrame from a csv file either from | ||
// a url, or from a file path. If all the fields of the top row of the csv contain | ||
// non-numeric data then the top row is assumed to be column headings. | ||
// | ||
// Each column of the DataFrame is held as a Series object, which is made up of a | ||
// slice of float64s, and the name of the column. Categorical (non-numeric) data | ||
// can also be held in a Series, but no calculations can be carried out on it. | ||
package gander |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package gander | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
) | ||
|
||
func ExampleLoadCSVFromPath() { | ||
df, err := LoadCSVFromPath("testdata/MOCK_DATA.csv") | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
fmt.Printf("%v\n", df.Columns()) | ||
// Output: 6 | ||
} | ||
|
||
func ExampleLoadCSVFromURL() { | ||
df, err := LoadCSVFromURL("http://download.tensorflow.org/data/iris_training.csv") | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
fmt.Printf("%v\n", df.Columns()) | ||
// Output: 5 | ||
} | ||
|
||
func ExampleNewDataFrame() { | ||
df, _ := NewDataFrame( | ||
[][]string{ | ||
{"a", "b", "c", "d", "e"}, | ||
{"1", "2", "3", "4", "5"}, | ||
{"3", "5", "2", "2", "4"}, | ||
{"7", "6", "1", "3", "3"}, | ||
{"4", "2", "4", "7", "6"}, | ||
}) | ||
fmt.Printf("%v\n", df.Rows()) | ||
// Output: 4 | ||
} | ||
|
||
func ExampleDataFrame_DropColumns() { | ||
df, _ := NewDataFrame( | ||
[][]string{ | ||
{"a", "b", "c", "d", "e"}, | ||
{"1", "2", "3", "4", "5"}, | ||
{"3", "5", "2", "2", "4"}, | ||
{"7", "6", "1", "3", "3"}, | ||
{"4", "2", "4", "7", "6"}, | ||
}) | ||
df.DropColumns(0, 2) | ||
fmt.Printf("%v\n", df.Columns()) | ||
// Output: 3 | ||
} | ||
|
||
func ExampleDataFrame_DropColumnsByName() { | ||
df, _ := NewDataFrame( | ||
[][]string{ | ||
{"a", "b", "c", "d", "e"}, | ||
{"1", "2", "3", "4", "5"}, | ||
{"3", "5", "2", "2", "4"}, | ||
{"7", "6", "1", "3", "3"}, | ||
{"4", "2", "4", "7", "6"}, | ||
}) | ||
df.DropColumnsByName("b", "d", "e") | ||
fmt.Printf("%v\n", df.Columns()) | ||
// Output: 2 | ||
} | ||
|
||
func ExampleDataFrame_DropColumnsWhere() { | ||
df, _ := NewDataFrame( | ||
[][]string{ | ||
{"a", "b", "c", "d", "e"}, | ||
{"1", "2", "3", "4", "5"}, | ||
{"3", "5", "2", "2", "4"}, | ||
{"7", "6", "1", "3", "3"}, | ||
{"4", "2", "4", "7", "6"}, | ||
}) | ||
df.DropColumnsWhere(func(s *Series) bool { | ||
return s.Name == "c" | ||
}) | ||
fmt.Printf("%v\n", df.Columns()) | ||
// Output: 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package gander | ||
|
||
// Load data and convert to a DataFrame | ||
|
||
import ( | ||
"strconv" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters