nextorch.io¶
Handles input and output
- nextorch.io.np_to_dataframe(X: Union[nextorch.utils.Matrix, list], var_names: Optional[Union[str, List[str]]] = None, n: Optional[int] = 1) pandas.DataFrame ¶
Convert a list numpy matrices to a single dataframe
- Parameters
- Returns
data – Output data
- Return type
- nextorch.io.read_csv(file_path: str, var_names: Optional[List[str]] = None, skiprows: Optional[list] = None, index_col: Optional[int] = 0, verbose: Optional[bool] = True) Tuple[pandas.DataFrame, pandas.DataFrame] ¶
Reads a csv file and returns the data in pandas Dataframe
- Parameters
file_path (str) – Path of the csv file
var_names (Optional[List[str]], optional) – Names of variables to include, by default None,
skiprows (Optional[list], optional) – Rows to skip at the beginning (0-indexed) by default None, i.e. import all
index_col (Optional[int], optional) – Column (0-indexed) to use as the row labels of the DataFrame by default 0 assuming the indices are saved in the first column
verbose (Optional[bool], optional) – Flag whether to output print statements, by default True
- Returns
data (pandas.DataFrame) – Input data
data_full (pandas.DataFrame) – Full data from the file
- nextorch.io.read_excel(file_path: str, sheet_name: Optional[str] = 0, var_names: Optional[List[str]] = None, skiprows: Optional[list] = None, index_col: Optional[int] = 0, verbose: Optional[bool] = True) Tuple[pandas.DataFrame, pandas.DataFrame] ¶
Reads an excel file and returns the data in pandas Dataframe
- Parameters
file_path (str) – Path of the excel spreedsheet
sheet_name (Optional[str], optional) – Name of the excel sheet, by default 0, i.e., the first sheet
var_names (Optional[List[str]], optional) – Names of variables to include, by default None,
skiprows (Optional[list], optional) – Rows to skip at the beginning (0-indexed) by default None, i.e. import all
index_col (Optional[int], optional) – Column (0-indexed) to use as the row labels of the DataFrame by default 0 assuming the indices are saved in the first column
verbose (Optional[bool], optional) – Flag whether to output print statements, by default True
- Returns
data (pandas.DataFrame) – Input data
data_full (pandas.DataFrame) – Full data from the file
- nextorch.io.split_X_y(data: pandas.DataFrame, Y_names: Union[str, List[str]], X_names: Optional[List[str]] = None) Tuple[nextorch.utils.Matrix, nextorch.utils.Matrix, List[str], List[str]] ¶
Splits the data into independent (X) and dependent (y) varibles
- Parameters
- Returns
X (Matrix) – Independent variable matrix
Y (Matrix) – Dependent variable matrix
X_names (List[str]) – Independent variables names
Y_names (List[str]) – Dependent variable matrix