Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
datascout
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ABP Computing
ABP Computing Sandbox
datascout
Commits
7bb5bbf6
There was an error fetching the commit references. Please try again later.
Commit
7bb5bbf6
authored
4 years ago
by
Davide Gamba
Browse files
Options
Downloads
Patches
Plain Diff
style
parent
41e8ed94
No related branches found
No related tags found
No related merge requests found
Pipeline
#2693678
passed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
datascout/_datascout.py
+13
-2
13 additions, 2 deletions
datascout/_datascout.py
docs/source/conf.py
+5
-5
5 additions, 5 deletions
docs/source/conf.py
with
18 additions
and
7 deletions
datascout/_datascout.py
+
13
−
2
View file @
7bb5bbf6
...
...
@@ -20,6 +20,7 @@ from pathlib import Path
# Functions needed to split 2D arrays
"""
def
_split_2D_array
(
val
,
in_memory
=
False
,
split_to_list
=
False
,
verbose
=
False
):
"""
It converts numpy 2D arrays into either 1D arrays or list of 1D arrays
...
...
@@ -104,6 +105,7 @@ def _convert_dict_list(data, in_memory=False, split_to_list=False, verbose=False
# Functions needed to re-merge 1D arrays of 1D arrays into 2D arrays
"""
def
_merge_to_2D
(
val
,
string_as_obj
=
False
,
verbose
=
False
):
"""
_merge_to_2D(val, string_as_obj=False, verbose=False)
...
...
@@ -181,6 +183,8 @@ def _revert_dict_list(data, in_memory=False, string_as_obj=False, verbose=False)
# CORE function of this project: it allows to convert a pyarrow object into a dict
#
"""
def
_convert_parrow_data
(
data
,
treat_str_arrays_as_str
=
True
,
use_list_for_2D_array
=
False
):
...
...
@@ -195,7 +199,7 @@ def _convert_parrow_data(
if use_list_for_2D_array (default=False) it will try to use lists of 1D arrays instead of 2D arrays
Typically the output should be a `dict`. If, however, one is trying to convert more complex structures
like a pyarrow Table or StructArray, the output will be a list of dictionaries if more than one data
like a pyarrow Table or StructArray, the output will be a list of dictionaries if more than one data
records are found.
"""
if
isinstance
(
data
,
pa
.
lib
.
Table
):
...
...
@@ -282,10 +286,11 @@ def _convert_parrow_data(
"""
######
######
# Some important functions not so interesting for the standard user, but fundamental
"""
def
dict_to_pyarrow
(
input_dict
):
my_data_dict_converted
=
_convert_dict_list
(
input_dict
,
in_memory
=
False
,
split_to_list
=
False
,
verbose
=
False
...
...
@@ -310,10 +315,12 @@ def pyarrow_to_dict(input_pa):
def
pyarrow_to_pandas
(
input_pa
):
return
dict_to_pandas
(
pyarrow_to_dict
(
input_pa
))
"""
####### The functions interesting for the user are the following ones:
"""
def
dict_to_pandas
(
input_dict
):
if
not
isinstance
(
input_dict
,
list
):
input_dict
=
[
input_dict
]
...
...
@@ -406,10 +413,12 @@ def parquet_to_pandas(filename):
def
parquet_to_awkward
(
filename
):
return
ak
.
from_parquet
(
filename
)
"""
####### Simple save/load functions for the user
"""
def
save_dict
(
dictData
,
folderPath
=
None
,
filename
=
None
,
fileFormat
=
"
parquet
"
):
if
filename
is
None
:
filename
=
datetime
.
now
().
strftime
(
"
%Y.%m.%d.%H.%M.%S.%f
"
)
...
...
@@ -442,10 +451,12 @@ def load_dict(filename, fileFormat="parquet"):
else
:
raise
ValueError
(
"
Unknown file format ({})
"
.
format
(
fileFormat
))
"""
####### Some additional functions for debugging purposes
"""
def
_find_lists
(
data
,
verbose
=
False
):
"""
Look inside data (assumed to be a dict) and tell if some fields are actually lists.
...
...
This diff is collapsed.
Click to expand it.
docs/source/conf.py
+
5
−
5
View file @
7bb5bbf6
...
...
@@ -16,11 +16,11 @@ copyright = "{0}, CERN".format(datetime.datetime.now().year)
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions
=
[
'
acc_py_sphinx.theme
'
,
'
sphinx.ext.autodoc
'
,
'
sphinx.ext.autosummary
'
,
'
sphinx.ext.doctest
'
,
'
sphinx.ext.napoleon
'
,
"
acc_py_sphinx.theme
"
,
"
sphinx.ext.autodoc
"
,
"
sphinx.ext.autosummary
"
,
"
sphinx.ext.doctest
"
,
"
sphinx.ext.napoleon
"
,
]
...
...
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