Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
brivas
mdf_reader
Commits
d526a3a4
Commit
d526a3a4
authored
5 years ago
by
iregon
Browse files
Options
Download
Email Patches
Plain Diff
Added some docstrings
parent
4e59e1ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
common/converters.py
common/converters.py
+26
-0
No files found.
common/converters.py
View file @
d526a3a4
...
...
@@ -34,7 +34,33 @@ class df_converters():
self
.
numeric_scale
=
1.
if
self
.
dtype
in
properties
.
numpy_floats
else
1
self
.
numeric_offset
=
0.
if
self
.
dtype
in
properties
.
numpy_floats
else
0
def
object_to_numeric
(
self
,
data
,
scale
=
None
,
offset
=
None
):
"""
Converts the object type elements of a pandas series to numeric type.
Right spaces are trated as ceros. Scale and offset can optionally be applied.
The final data type according to the class dtype.
Parameters
----------
self : dtype, numeric_scale and numeric_offset
Pandas dataframe with a column per report sections.
The sections in the columns as a block strings.
data : pandas.Series
Series with data to convert. Data must be object type
Keyword Arguments
-----------------
scale : numeric, optional
Scale to apply after conversion to numeric
offset : numeric, optional
Offset to apply after converion to numeric
Returns
-------
data : pandas.Series
Data series of type self.dtype
"""
scale
=
scale
if
scale
else
self
.
numeric_scale
offset
=
offset
if
offset
else
self
.
numeric_offset
# First do the appropriate managing of white spaces:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment