Crysda
CrysDAis a **{Crys}**tal shard for **{D}**ata **{A}**nalysis. Provides you modern functional-style API for data manipulation to filter, transform, aggregate and reshape tabular data. Core of the library isCrysDA::DataFrame` an immutable data structure interface.
Features
- [X] Filter, transform, aggregate and reshape tabular data
- [X] Modern, user-friendly and easy-to-learn data-science API
- [X] Reads from plain and compressed tsv, csv, json, or any delimited format with or without header from local or remote.
- [X] Supports grouped operations
- [X] Supports reading data from DB
- [X] Tables can contain atomic columns (Number, Float, Bool, String) as well as object columns
- [X] Reshape tables from wide to long and back
- [X] Table joins (left, right, semi, inner, outer)
- [X] Cross tabulation
- [X] Descriptive statistics (mean, min, max, median, ...)
- [X] Functional API inspired by dplyr, pandas
- [X] many more...
Constants
Class methods
Binds dataframes by column. Rows are matched by position, so all data frames must have the same number of rows.
Adds new rows. Missing entries are set to null. The output of bind_rows will contain a column if that column appears in any of the inputs. When row-binding, columns are matched by name, and any missing columns will be filled with NA. Grouping will be discarded when binding rows
return column types as an array of ColSpec struct
Concatenate multiple DataFrames axis: 0 for vertical (row-wise), 1 for horizontal (column-wise)
Creates a new data-frame from Array of {} of String => Any
Creates a new data-frame from array of DataFrameRow
Creates a new dataframe in place.
header - pass headers as variadic parameter
call values after this call to pass the values
df = dataframe_of("quarter", "sales", "location").values(1, 300.01, "london", 2, 290, "chicago")
Creates a new data-frame from records encoded as key-value maps Column types will be inferred from the value types
reads a comma separated value file/io into a dataframe.
file could be local file path or a URL. It will read compressed(gz, gzip) files.
separator defaults to , and can be changed to other separator (e.g \t for tab separated files)
skip_blank_lines defaults to true, will skip all blank lines
skip defaults to 0, will skip this much lines from start of file.
comment character default # will ignore all lines starting with this character
header line defaults to 0 (first row), if set to nil then column names are auto generated starting with Col1.
if skip_blank_lines and comment are enabled, header will start reading after removing blank and comment lines
na_value defaults to NA Strings which should be treated as Nil. values matching this param will be treated as nil
true_values defaults to ["T","TRUE"] values to consider as boolean true
false_values defaults to ["F","FALSE"] values to consider as boolean false
helper method to return the block as Proc. Used when doing select with multiple criteria.
Kind of workaround as Crystal doesn't allow variadic blocks and Proc definition requires
complete signature like Crysda::ColumnSelector.new{|e| ....}
so instead of
df.select(
Crysda::ColumnSelector.new { |s| ... },
Crysda::ColumnSelector.new { |s| ... }
)
One can simply use this helper
df.select(
Crysda.selector{|e| ....},
Crysda.selector{|e| ....},
)
Nested types
- Crysda::AggFunc
- Crysda::AggFuncs
- Crysda::Any
- Crysda::AnyCol
- Crysda::AnyVal
- Crysda::BigDecimalCol
- Crysda::BoolCol
- Crysda::ColNames
- Crysda::ColSpec
- Crysda::ColumnException
- Crysda::ColumnFormula
- Crysda::ColumnNotFoundException
- Crysda::ColumnSelector
- Crysda::CrysdaException
- Crysda::CustomColumnValue
- Crysda::DFCol
- Crysda::DataCol
- Crysda::DataFrame
- Crysda::DataFrameRow
- Crysda::DateTimeCol
- Crysda::DuplicateColumnNameException
- Crysda::Float64Col
- Crysda::HashBuilder
- Crysda::Int32Col
- Crysda::Int64Col
- Crysda::InvalidColumnOperationException
- Crysda::InvalidColumnSelectException
- Crysda::InvalidSortingPredicateException
- Crysda::List(T)
- Crysda::MissingValueException
- Crysda::NonScalarValueException
- Crysda::NullBitmap
- Crysda::RenamePair
- Crysda::RenameRule
- Crysda::RowPredicate
- Crysda::SelectException
- Crysda::SortExpression
- Crysda::StringCol
- Crysda::StringPool
- Crysda::SumFormula
- Crysda::SummarizeFunc
- Crysda::TableExpression
- Crysda::TimestampCol
- Crysda::UnSupportedOperationException