Importing & Exporting

Although data analysis is primarily done through the pandas.Series type, it is possible to directly import data from an MS Excel or CSV formatted file. Under the hood, these ultimately utilize pandas importing tools but are convenient when data is formatted with the control limits located in the headers.

Importing from CSV

Data Format

Data may be imported from a CSV file. The expected format of the imported data is as follows:

header0,header1 (usl=X lsl=Y),header2
1,2,3
4,5,6
7,8,9
...

Things to notice:

  • The specification limit values X and Y are specified in the header for one of the columns.

  • The specification limit values are not specified in the other columns.

Usage

The manufacturing.import_csv is utilized for the import operation. If specification limits are not in the header, then the data will be directly imported into a pandas.Series:

data = manufacturing.import_csv('data.csv',
                                columnname='header0')

This method brings in the data, but doesn’t bring in the specification limits. The data is brought in as a pandas.Series and all of the operations that may be done with a pandas.Series apply.

A somewhat more useful use case is when the specification limits are embedded within the column header. For instance:

data = manufacturing.import_csv('data.csv',
                                columnname='header1 (lsl=2.0 usl=3.0)')

In this case, the data contains a dictionary with keys data, upper_specification_limit, and lower_specification_limit. These keys are utilized throughout the library analysis and plotting tools, which is why they are imported directly here.

manufacturing.import_csv(file_path: (<class 'str'>, <class 'pathlib.Path'>), columnname: str, **kwargs) Union[dict, pandas.core.series.Series]

Imports data from a csv file and outputs the specified column of data as a pandas.Series

Parameters
  • file_path – the path to the file on the local file system

  • columnname – the column name to which the data is associated

  • kwargs – keyword arguments to be passed directly into pandas.read_csv()

Returns

a dict containing a pandas series and the limits of the data to be analyzed

Importing from MS Excel

Data Format

Data may be imported from an MS Excel file. Much like importing from CSV, the expected format of the imported data is as follows:

header0,header1 (lsl=X usl=Y),header2

Usage

The manufacturing.import_excel is utilized for the import operation. If specification limits are not in the header, then the data will be directly imported into a pandas.Series:

data = manufacturing.import_excel('data.xlsx',
                                  columnname='header0')

This method brings in the data, but doesn’t bring in the specification limits. The data is brought in as a pandas.Series and all of the operations that may be done with a pandas.Series apply.

A somewhat more useful use case is when the specification limits are embedded within the column header. For instance:

data = manufacturing.import_excel('data.xlsx',
                                  columnname='header1 (lsl=2.0 usl=3.0)')

In this case, the data contains a dictionary with keys data, upper_specification_limit, and lower_specification_limit. These keys are utilized throughout the library analysis and plotting tools, which is why they are imported directly here.

manufacturing.import_excel(file_path: (<class 'str'>, <class 'pathlib.Path'>), columnname: str, **kwargs) Union[dict, pandas.core.series.Series]

Imports data from an excel file and outputs the specified column of data as a pandas.Series

Parameters
  • file_path – the path to the file on the local file system

  • columnname – the column name to which the data is associated

  • kwargs – keyword arguments to be passed directly into pandas.read_excel()

Returns

a pandas series of the data which is to be analyzed