Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
V
Variable derivation
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Uncover
Variable derivation
Commits
567e0113
Commit
567e0113
authored
Nov 15, 2021
by
Alberto Blázquez Herranz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed exception (nan).
parent
b85791a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
__pycache__/numeric_converter.cpython-37.pyc
__pycache__/numeric_converter.cpython-37.pyc
+0
-0
numeric_converter.py
numeric_converter.py
+17
-3
No files found.
__pycache__/numeric_converter.cpython-37.pyc
View file @
567e0113
No preview for this file type
numeric_converter.py
View file @
567e0113
...
...
@@ -43,15 +43,29 @@ def numeric_conversion(datafile):
verify_num_col
=
[
x
for
x
in
datafile
.
columns
if
x
in
numeric_variables
]
for
col
in
verify_num_col
:
newdata
=
[]
for
x
in
datafile
[
col
]:
try
:
newdata
.
append
(
float
(
x
))
except
:
newdata
.
append
(
None
)
datafile
[
col
]
=
[
float
(
x
)
if
str
(
x
)
==
"nan"
else
None
for
x
in
datafile
[
col
]]
datafile
[
col
]
=
newdata
#datafile[col] = [float(x) if str(x) !="nan" else None for x in datafile[col]]
verify_cat_col
=
[
x
for
x
in
datafile
.
columns
if
x
in
categorical_variables
]
for
col
in
verify_cat_col
:
datafile
[
col
]
=
[
str
(
x
)
if
str
(
x
)
==
"nan"
else
None
for
x
in
datafile
[
col
]]
newdata
=
[]
for
x
in
datafile
[
col
]:
try
:
newdata
.
append
(
str
(
x
))
except
:
newdata
.
append
(
None
)
datafile
[
col
]
=
newdata
#datafile[col] = [str(x) if str(x) !="nan" else None for x in datafile[col]]
#new_datafile_path = datafile_path.replace(".csv", "_numeric.csv")
#datafile.to_csv(new_datafile_path, index = False, quoting=csv.QUOTE_NONNUMERIC)
...
...
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