Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NIRS_Workflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CEFE
PACE
NIRS_Workflow
Commits
a4a322a4
Commit
a4a322a4
authored
1 year ago
by
Nicolas Barthes
Browse files
Options
Downloads
Patches
Plain Diff
autodetect column index True or False when importing CSV data
parent
3232d795
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.py
+2
-3
2 additions, 3 deletions
app.py
application_functions.py
+5
-1
5 additions, 1 deletion
application_functions.py
with
7 additions
and
4 deletions
app.py
+
2
−
3
View file @
a4a322a4
...
...
@@ -8,7 +8,7 @@ import pandas as pd
import
plotly.express
as
px
from
sklearn.cluster
import
KMeans
as
km
from
sklearn.metrics
import
pairwise_distances_argmin_min
from
application_functions
import
pca_maker
,
model
,
predict
,
find_delimiter
,
umap_maker
from
application_functions
import
pca_maker
,
model
,
predict
,
find_delimiter
,
umap_maker
,
find_col_index
# load images for web interface
img_sselect
=
Image
.
open
(
"
images\sselect.JPG
"
)
...
...
@@ -43,12 +43,11 @@ with st.container():
# Select list for CSV delimiter
psep
=
settings_column
.
selectbox
(
"
Select csv separator - _detected_:
"
+
str
(
find_delimiter
(
'
data/
'
+
sselectx_csv
.
name
)),
options
=
[
"
;
"
,
"
,
"
],
index
=
[
"
;
"
,
"
,
"
].
index
(
str
(
find_delimiter
(
'
data/
'
+
sselectx_csv
.
name
))),
key
=
9
)
# Select list for CSV header True / False
phdr
=
settings_column
.
selectbox
(
"
indexes column in csv?
"
,
options
=
[
"
no
"
,
"
yes
"
]
,
key
=
31
)
phdr
=
settings_column
.
selectbox
(
"
indexes column in csv?
- _detected_:
"
+
str
(
find_col_index
(
'
data/
'
+
sselectx_csv
.
name
)),
options
=
[
"
no
"
,
"
yes
"
],
index
=
[
"
no
"
,
"
yes
"
].
index
(
str
(
find_col_index
(
'
data/
'
+
sselectx_csv
.
name
)))
,
key
=
31
)
if
phdr
==
'
yes
'
:
col
=
0
else
:
col
=
False
data_import
=
pd
.
read_csv
(
sselectx_csv
,
sep
=
psep
,
index_col
=
col
)
# Select type of plot
plot_type
=
[
''
,
'
pca
'
,
'
umap
'
]
...
...
This diff is collapsed.
Click to expand it.
application_functions.py
+
5
−
1
View file @
a4a322a4
...
...
@@ -19,7 +19,11 @@ def find_delimiter(filename):
with
open
(
filename
)
as
fp
:
delimiter
=
sniffer
.
sniff
(
fp
.
read
(
5000
)).
delimiter
return
delimiter
def
find_col_index
(
filename
):
with
open
(
filename
)
as
fp
:
lines
=
pd
.
read_csv
(
fp
,
skiprows
=
3
,
nrows
=
3
,
index_col
=
False
,
sep
=
str
(
find_delimiter
(
filename
)))
col_index
=
'
yes
'
if
lines
.
iloc
[:,
0
].
dtypes
!=
np
.
float64
else
'
no
'
return
col_index
# detection of columns categories and scaling
def
col_cat
(
data_import
):
# detect numerical and categorical columns in the csv
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment