Documentation ¶
Overview ¶
Package po implements a Pandas-like library for go. Po provides Series and DataFrame datastructures for data munging and preparation. Inspired by https://github.com/pandas-dev/pandas and https://github.com/kniren/gota
Index ¶
- Constants
- func IntGenerator(start int, end int, step int, exclude []int) []int
- func WriteCsv(w io.Writer, df DataFrame) error
- type DataFrame
- func (df DataFrame) Columns() []string
- func (df DataFrame) Copy() DataFrame
- func (df DataFrame) Dims() (int, int)
- func (df DataFrame) DropColumns(c ...string) DataFrame
- func (df DataFrame) Head(i ...int) DataFrame
- func (df DataFrame) Pick(i ...int) DataFrame
- func (df DataFrame) Rename(c map[string]string) DataFrame
- func (df DataFrame) Select(c ...string) DataFrame
- func (df DataFrame) Shape() (int, int)
- func (df DataFrame) String() string
- func (df DataFrame) Subset(start int, end int, step int, exclude []int) DataFrame
- func (df DataFrame) Transpose() DataFrame
- type Series
Constants ¶
const ( // HeadSize is the default return length of the Head() // for both a Series and a DataFrame HeadSize = 5 // RandStringLen is the default length for the randomly generated // column names, if and when they are needed. RandStringLen = 5 )
Variables ¶
This section is empty.
Functions ¶
func IntGenerator ¶
IntGenerator generates a slice of integers that can then be used to apply different functions on DataFrames or Series, such as Subset() or Pick().
Types ¶
type DataFrame ¶
DataFrame is a map datastructure containing Series values. It is intended to represent a generic table where the keys correspond to the individual column names and the rows correspond to the original input series. Column names can be generated on DataFrame instantiation via literal construct, or via the NewDataFrame()
func GenerateDataFrame ¶
GenerateDataFrame generates a DataFrame with size n of randomized user profile data. The data is generated using the github.com/Pallinder/go-randomdata package
func NewDataFrame ¶
NewDataFrame returns a new DataFrame object with rows corresponding to provided ss and column names corresponding to provided Columns. If no ss is provided, then an empty dataframe will be created using any provided column names. If the number of Columns provided < len(ss) for any given ss, then the column names will be auto generated for the remaining entries. If the len(Columns) > len(ss) for any given ss, then the ss will be extended with empty string values for each remaining col.
func ReadCsv ¶
ReadCsv reads in csv data and returns a DataFrame with randomly generated column names for each input column.
func (DataFrame) Columns ¶
Columns returns all of the column names sorted for maintaining order. The sorting is done using the sort.String() method from the std lib.
func (DataFrame) DropColumns ¶
DropColumns removes columns from the DataFrame.
func (DataFrame) Head ¶
Head returns the first i entries for each column in a DataFrame. If a slice of ints is passed, only the first entry is used. I used the varargs operator to allow for optional entry. In the case where no i is passed, then default to returning the HeadSize or the len DataFrame rows whichever is smaller. If a neg value is passed then the abs value is used.
func (DataFrame) Rename ¶
Rename renames the columns in the dataframe that correspond to the provided keys in the map parameter.
func (DataFrame) Select ¶
Select returns a subset of the original DataFrame with only the given column names n represented.
func (DataFrame) Shape ¶
Shape returns the number of rows, number of columns in a DataFrame. Same as po.DataFrame.Dims()
func (DataFrame) String ¶
String returns the string representation of the DataFrame. Columns are ordered via sort.Strings() method. It uses the olekukonko/tablewriter library to render the table.
type Series ¶
type Series []string
Series is a generic datastructure that contains a slice of strings. Strings were chosen as the type of choice since I wanted to make the api simple, easy to use, and as close to the pandas api as possible so that the learning curve would be small. This allows the user to input any type of data they want into a Series, (so long as it is surrounded by ""). There are casting operations that can be performed on a Series to perform different mathmatical operations which require non string types.
func NewSeries ¶
NewSeries is a variadic function that returns a Series comprised of the provided strings
func (Series) Head ¶
Head returns the first i entries in a series. If a slice of ints is passed, only the first entry is used. I used the varargs operator to allow for optional entry. In the case where no i is passed, then default to returning the HeadSize or the len(Series) whichever is smaller. If a neg value is passed then the abs value is used.
func (Series) String ¶
String returns the string representation of the Series. It uses the olekukonko/tablewriter library to render the table.