Public Member Functions | |
| rows (self) | |
| cols (self) | |
| cols (self, val) | |
| get_book (self) | |
| lt_col_index (self, col, convert_negative=False) | |
| from_df (self, df, c1=0, addindex=False, head='') | |
| to_df (self, c1=0, numcols=-1, cindex=-1, head='') | |
| to_list (self, col) | |
| from_list (self, col, data, lname='', units='', comments='', axis='', start=0) | |
| get_label (self, col, type='L') | |
| set_label (self, col, val, type='L') | |
| get_labels (self, type_='L') | |
| set_labels (self, labels, type_='L', offset=0) | |
| from_dict (self, data, col=0, row=0) | |
| header_rows (self, spec='') | |
| cols_axis (self, spec='', c1=0, c2=-1, repeat=True) | |
| del_col (self, c1, nc=1) | |
| clear (self, c1=0, ncols=0, c2=-1) | |
| sort (self, col, dec=False) | |
| to_list2 (self, r1=0, r2=-1, c1=0, c2=-1) | |
| from_list2 (self, data, row=0, col=0) | |
| as_date (self, col, fmt) | |
| as_time (self, col, fmt) | |
| move_cols (self, n, c1, ncols=1) | |
| plot_cloneable (self, template) | |
| set_formula (self, col, formula) | |
| report_table (self, *args) | |
| to_xy_range (self, colx, coly, colyerr, colxerr='') | |
| to_col_range (self, col) | |
| merge_label (self, type_='L', unmerge=False) | |
| cell (self, row, col) | |
| set_cell_note (self, row, col, text) | |
Public Member Functions inherited from originpro.base.DSheet | |
| __str__ (self) | |
| __repr__ (self) | |
| shape (self) | |
| shape (self, val) | |
| remove_DC (self) | |
| has_DC (self) | |
| from_file (self, fname, keep_DC=True, dctype='', sel='', sparks=False) | |
| lt_range (self, use_name=True) | |
| tabcolor (self) | |
| tabcolor (self, rgb) | |
Public Member Functions inherited from originpro.base.BaseLayer | |
| activate (self) | |
| destroy (self) | |
| label (self, name) | |
| remove_label (self, label) | |
| add_label (self, text, x=None, y=None) | |
| add_line (self, x1, y1, x2, y2) | |
Public Member Functions inherited from originpro.base.BaseObject | |
| __init__ (self, obj) | |
| __del__ (self) | |
| __bool__ (self) | |
| index (self) | |
| get_str (self, prop) | |
| get_int (self, prop) | |
| get_float (self, prop) | |
| set_str (self, prop, value) | |
| set_int (self, prop, value) | |
| set_float (self, prop, value) | |
| method_int (self, name, arg='') | |
| method_float (self, name, arg='') | |
| method_str (self, name, arg='') | |
| lt_exec (self, labtalk) | |
| name (self) | |
| name (self, value) | |
| lname (self) | |
| lname (self, value) | |
| comments (self) | |
| comments (self, value) | |
| show (self) | |
| show (self, value) | |
| usertree (self) | |
| usertree (self, tr) | |
| userprops (self) | |
Public Attributes | |
| cols = self.cols | |
| obj | |
Public Attributes inherited from originpro.base.DSheet | |
| obj | |
Public Attributes inherited from originpro.base.BaseLayer | |
| obj | |
Public Attributes inherited from originpro.base.BaseObject | |
| obj = obj | |
Protected Member Functions | |
| _check_add_cols (self, needecols, c1=0) | |
| _col_label_row (self, head='') | |
| _user_param_row (self, name, add=False) | |
| _col_index (self, col, convert_negative=False) | |
| _find_col (self, col) | |
| _as_datetime (self, dt_, customfmt, col, fmt) | |
| _to_lt_str (self, col) | |
Protected Member Functions inherited from originpro.base.DSheet | |
| _get_book (self) | |
Static Protected Member Functions | |
| _set_col_LN (colobj, key, col) | |
| _isParam (name, prefix) | |
| _getlabel (colobj, type) | |
| _setlabel (colobj, type, val) | |
| _cname (colobj, type) | |
| _cgetdata (colobj, nStart=0, nEnd=-1) | |
This class represents an Origin Worksheet, it holds an instance of a PyOrigin Worksheet.
|
protected |
return int if user parameter row, or 'L', 'C', 'U' etc
|
staticprotected |
type is int if user parameter row, or 'L', 'C', 'U' etc, see _col_label_row()
|
protected |
return empty str if not valid, otherwise return LabTalk column index as str
|
protected |
find user defined parameter row index from name, if add, then add it if not existed
| originpro.worksheet.WSheet.as_date | ( | self, | |
| col, | |||
| fmt ) |
set col as date format
Parameters:
col (int or str): If int, column index. If str, column name, short name first, then long name.
fmt (int or str): can be custom format string, or date display option as int
Returns:
(None)
Examples:
wks=op.find_sheet()
data = [1,2,3,4,5,6]
wks.from_list(0, data)
wks.as_date(0, "yyyy'Q'q")
See Also:
| originpro.worksheet.WSheet.as_time | ( | self, | |
| col, | |||
| fmt ) |
set col as time format
Parameters:
col (int or str): If int, column index. If str, column name, short name first, then long name.
fmt (int or str): can be custom format string, or time display option as int
Returns:
(None)
Examples:
wks=op.find_sheet()
data = [1.1,2.2,3.3,4.4,5.5,6.6]
wks.from_list(0, data)
wks.as_time(0, "D:hh':'mm':'ss TT")
See Also:
| originpro.worksheet.WSheet.cell | ( | self, | |
| row, | |||
| col ) |
It returns the contents of a worksheet cell as a string.
Parameters:
row (int): the row index.
col (int, str): if int, it is the column index, otherwise the column name
Returns:
(str) the contents of a worksheet cell as a string.
Examples:
wks=op.find_sheet()
ls = [1,2,3]
wks.from_list(0,ls)
nVal = wks.cell(0,0)
print(nVal)
| originpro.worksheet.WSheet.clear | ( | self, | |
| c1 = 0, | |||
| ncols = 0, | |||
| c2 = -1 ) |
Clear data in worksheet
Parameters:
c1 (int or str): starting col, if int, column index. If str, column name, short name first, then long name.
ncols(int): number of columns to clear if > 0, cannot specify togeher with c2
c2 (int or str): ending col, if int, column index. If str, column name, short name first, then long name.
Returns:
(int): 0 for success, otherwise an internal error code
Examples:
wks.clear()#clear all
wks.clear(1)#clear from 2nd column to the end
wks.clear(1,2)#clear from 2nd and 3rd
| originpro.worksheet.WSheet.cols | ( | self | ) |
get the last column index in worksheet, this is the same as shape[1]
Parameters:
Returns:
get the last column index in worksheet
Examples:
wks=op.find_sheet()
ncols = wks.cols
| originpro.worksheet.WSheet.cols | ( | self, | |
| val ) |
set the number of columns in worksheet
Parameters:
val(int):number of columns
Returns:
the last column index in worksheet
Examples:
wks=op.find_sheet()
wks.cols=5
| originpro.worksheet.WSheet.cols_axis | ( | self, | |
| spec = '', | |||
| c1 = 0, | |||
| c2 = -1, | |||
| repeat = True ) |
Set column plotting designations with a string pattern.
Parameters:
spec (str): A combination of 'x', 'y', 'z', etc letters
c1 (int or str): Starting column to set
c2 (int or str): Last column to set. c2 < 0 sets to last column
repeat (bool): Repeat the last designation letter or not
Returns:
None
Examples:
wks.cols_axis('nxy') # 1st col none, 2nd=x, others=y.
wks.cols_axis() # Clear designations from all columns.
| originpro.worksheet.WSheet.del_col | ( | self, | |
| c1, | |||
| nc = 1 ) |
Delete worksheet columns
Parameters:
c1 (int or str): Starting column to delete, <0 supported as from the end
nc (int): Number of columns to delete starting from c1
Examples:
wks.del_col(0)# del col A
wks.del_col('C', 2)#del col C and D
| originpro.worksheet.WSheet.from_df | ( | self, | |
| df, | |||
| c1 = 0, | |||
| addindex = False, | |||
| head = '' ) |
Sets a pandas DataFrame to an Origin worksheet.
Parameters:
df (DataFrame): Input DataFrame object
c1 (int or str): Starting column index
addindex (bool): add an index column at c1 if df has text indices
head(str): if not specified, column longname is used if df has column names,
head can be one of the Column Label Row character like 'L', 'C', or a user parameter by its name
Returns:
None
Examples:
wks=op.find_sheet()
my_df = pd.DataFrame({'aa':[1,2,3], 'bb':[4,5,6]})
wks.from_df(my_df)
import pandas as pd
fname = op.path('e') + "Samples\\Import and Export\donations.csv"
df = pd.read_csv(fname)
wks.from_df(df,'B')
| originpro.worksheet.WSheet.from_dict | ( | self, | |
| data, | |||
| col = 0, | |||
| row = 0 ) |
Set a dictionary into a Worksheet. Keys are not used for any purpose.
Parameters:
data (dict): The data to set
col (int or str): If int, column index. If str, tries short name and if not exists, tries column long name
row (int): Row index to start setting the data
Returns:
None
Examples:
data ={'aa': [1,2,3], 'bb':[4,5,6]}
wks.from_dict(data)
wks.from_dict(data,'C')
| originpro.worksheet.WSheet.from_list | ( | self, | |
| col, | |||
| data, | |||
| lname = '', | |||
| units = '', | |||
| comments = '', | |||
| axis = '', | |||
| start = 0 ) |
Sets a list object into an Origin column, optionally specifying long name, units ,comments label row values.
Parameters:
col (int or str): If int, column index. If str, tries short name and if not exists, tries column long name
data (list): data to put into column
lname (str): Optional column long name
units (str): Optional column units
comments (str): Optional column comments
axis (str): empty will not set, otherwise set column designation for plotting,
can be X,Y,Z, or N(None), E(Yerr), M(Xerr), L(label)
see https://www.originlab.com/doc/Origin-Help/WksCol-SetDesignation
start(int): row offset
Returns:
None
Examples:
data = [1,2,3,4,5]
wks.from_list(1, data)
wks.from_list('Intensity', data, units='a. u.', axis='Y')
wks.from_list(0, data, start=2)
| originpro.worksheet.WSheet.from_list2 | ( | self, | |
| data, | |||
| row = 0, | |||
| col = 0 ) |
set a block of cells
Parameters:
data (list): a list of lists of values
row (int): starting row index
col (int or str): starting col, by index of by name
Returns:
(None)
Examples:
wks=op.find_sheet()
#append a row to worksheet
data = [ [10], [40] ]
wks.from_list2(data, wks.rows)
See Also:
to_list2
| originpro.worksheet.WSheet.get_book | ( | self | ) |
Returns parent book of sheet.
Parameters:
Returns:
(WBook)
Examples:
wks2 = wks.get_book().add_sheet('Result')
Reimplemented from originpro.base.DSheet.
| originpro.worksheet.WSheet.get_label | ( | self, | |
| col, | |||
| type = 'L' ) |
Return a column label row text.
Parameters:
col (int or str): If int, column index. If str, tries short name and if not exists, tries column long name
type (str): A column label row character (see https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters) or a user defined parameter name. Note: the maximum number of user defined labels is 128.
Returns:
(str)
Examples:
wks=op.find_sheet()
comments = wks.get_label(1,'C')
| originpro.worksheet.WSheet.get_labels | ( | self, | |
| type_ = 'L' ) |
Return columns label row text.
Parameters:
type_ (str): A column label row character (see https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters) or a user defined parameter name
Returns:
(list)
Examples:
wks=op.find_sheet()
comments = wks.get_labels('C')
Reimplemented from originpro.base.DSheet.
| originpro.worksheet.WSheet.header_rows | ( | self, | |
| spec = '' ) |
Controls which worksheet label rows to show, same as LabTalk wks.labels string.
Parameters:
spec (str): A combination of letters. See https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters
Returns:
None
Examples:
wks.header_rows('lu')# Show only long-name and unit.
wks.header_rows()# Remove all label rows, keep only heading.
| originpro.worksheet.WSheet.lt_col_index | ( | self, | |
| col, | |||
| convert_negative = False ) |
convert a 0-offset index to LabTalk index which is 1-offset
Parameters:
col (int or str): If int, column index. If str, tries short name and if not exists, tries column long name, <0 supported as from the end
Return:
(int) 1-offset column index
Examples:
ii = wks.lt_col_index('Intensity')
if ii < 1:
print('no such column')
| originpro.worksheet.WSheet.merge_label | ( | self, | |
| type_ = 'L', | |||
| unmerge = False ) |
merge or unmerge specified label row
Parameters:
type_(string):can be 'L' for longname, 'U' for Units, 'C' for comments
unmerge(bool):false for merge, true for unmerge
Returns:
(None)
Examples:
wks=op.find_sheet()
arrLName = ['longname','longname']
wks.set_labels(arrLName)
wks.merge_label()
| originpro.worksheet.WSheet.move_cols | ( | self, | |
| n, | |||
| c1, | |||
| ncols = 1 ) |
moves a contiguous set of columns
Parameters:
n (int): by how many positions to move; if negative, columns are moved left,
otherwise right.
c1 (int): the index of the first columns in the contiguous set.
ncols (int): the total number of columns in the contiguous set.
Returns:
(bool) returns True for success.
Examples:
wks=op.find_sheet()
wks.move_cols(2, 1, 3) # it moves three columns, beginning with the second column,
# by two positions right.
See Also:
| originpro.worksheet.WSheet.plot_cloneable | ( | self, | |
| template ) |
Plots workbook data into a cloneable graph template
Parameters:
template (str): Cloneable graph template name.
Returns:
(None)
Example:
ws = op.new_book('w', hidden = False)[0]
ws.from_file(op.path('e') + r'Samples\Statistics\Automobile.dat', True)
ws.plot_cloneable('mytemplate')
| originpro.worksheet.WSheet.report_table | ( | self, | |
| * | args ) |
Get Report table as DataFrame
Parameters:
args: Table names as string
Example:
wks = op.find_sheet()
df1 = wks.report_table("Parameters")
| originpro.worksheet.WSheet.rows | ( | self | ) |
Get the last row index in worksheet with data, hidden rows has no effect on this
This is different from shape[0] which does not care of having data or not
Parameters:
Returns:
the last row index in worksheet with data
Examples:
wks=op.find_sheet()
nrows = wks.rows
| originpro.worksheet.WSheet.set_cell_note | ( | self, | |
| row, | |||
| col, | |||
| text ) |
create or update a cell's Note
Parameters:
row (int): the row index.
col (int, str): if int, it is the column index, otherwise the column name
text (str): The cell note content
Returns:
(None)
Examples:
wks=op.find_sheet()
wks.set_cell_note(0,0,'test cell note')
| originpro.worksheet.WSheet.set_formula | ( | self, | |
| col, | |||
| formula ) |
set column formula
Parameters:
col (int or str): If int, column index. If str, column name, short name first, then long name.
formula(str): column formula (Fx) to set.
Example:
wks = op.find_sheet()
wks.set_formula('B', 'A+1')
| originpro.worksheet.WSheet.set_label | ( | self, | |
| col, | |||
| val, | |||
| type = 'L' ) |
Set a column label row text.
Parameters:
col (int or str): If int, column index. If str, tries short name and if not exists, tries column long name
val (str): the text to set
type (str): A column label row character (see https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters) or a user defined parameter name. Note: the maximum number of user defined labels is 128.
Examples:
wks=op.find_sheet()
wks.set_label('A','long name for col A')
wks.set_label(1, 'for col B, add user parameter if not there', 'Channel')
| originpro.worksheet.WSheet.set_labels | ( | self, | |
| labels, | |||
| type_ = 'L', | |||
| offset = 0 ) |
Set columns label row text.
Parameters:
labels (list): the text to set
type_ (str): A column label row character (see https://www.originlab.com/doc/LabTalk/ref/Column-Label-Row-Characters) or a user defined parameter name
Examples:
wks=op.find_sheet()
wks.set_labels(['long name for col A', 'long name for col B'], 'L')
Reimplemented from originpro.base.DSheet.
| originpro.worksheet.WSheet.sort | ( | self, | |
| col, | |||
| dec = False ) |
Sort worksheet data by a specified column
Parameters:
col (int or str): If int, column index (1-offset). If str, column name, short name first, then long name.
dec (bool): Ascending(False) or Descending(True)
Returns:
(int): 0 for success, otherwise an internal error code
Examples:
wks.sort('A')#sort using 1st col, ascending
wks.sort(0, True)#sort using 1st col, descending
| originpro.worksheet.WSheet.to_col_range | ( | self, | |
| col ) |
Make Column range string
Parameters:
col(int or str): If int, column index. If str, tries short name and if not exists, tries column long name
Returns:
XY range string
Examples:
wks=op.find_sheet()
wks.cols=3
strRange = wks.to_col_range(1)
| originpro.worksheet.WSheet.to_df | ( | self, | |
| c1 = 0, | |||
| numcols = -1, | |||
| cindex = -1, | |||
| head = '' ) |
Creates a pandas DataFrame from an Origin worksheet.
Parameters:
c1 (int or str): column to start the export
numcols (int): Total number of columns, -1 to the end
cindex (int or str): Column to use for DataFrame index if specified
head (str): user parameter or built-in label row name, if not specified, lname(column long name), or short name if lname empty or duplicated
Returns:
(DataFrame)
Examples:
df = wks.to_df(2)#from 3rd column
#use col(A) as index, and B and C as data
df1 = wks.to_df('B', 2, 'A')
#to use a user defined label row as column heading
df2 = wks.to_df(head='Tag')
| originpro.worksheet.WSheet.to_list | ( | self, | |
| col ) |
Creates a list object from the data in an Origin column.
Parameters:
col (int or str): If int, column index. If str, tries short name and if not exists, tries column long name
Returns:
(list)
Examples:
data1 = wks.to_list(1)
data2 = wks.to_list('Intensity')
| originpro.worksheet.WSheet.to_list2 | ( | self, | |
| r1 = 0, | |||
| r2 = -1, | |||
| c1 = 0, | |||
| c2 = -1 ) |
get a block of cells as a list of lists
Parameters:
r1 (int): beginning row index
r2 (int): ending row index (inclusive), -1 to the end
c1 (int): beginning column index
c2 (int): ending column index (inclusive), -1 to the end
Returns:
(list) list of lists of results
Examples:
#copy 1st row and append to last row
ll = wks.to_list2(0,0)
wks.from_list2(ll,wks.rows)
| originpro.worksheet.WSheet.to_xy_range | ( | self, | |
| colx, | |||
| coly, | |||
| colyerr, | |||
| colxerr = '' ) |
Make XY range string from columns
Parameters:
colx, coly, colyerr, colxerr:type can be int or str, If int, column index. If str, tries short name and if not exists, tries column long name
Returns:
XY range string
Examples:
wks=op.find_sheet()
wks.cols=3
strRange = wks.to_xy_range(0,1,2)