pr/3
#3
by
keeganskeate
- opened
No description provided.
keeganskeate
changed pull request status to
open
This pull request incorporates improvements found during a rigorous testing of CoADoc
: the parsing of a dataset of public cannabis lab test results published by Raw Garden. There's a whole lot of cleaning to be done on this data! For example, there's a value
of '<LLoQ'
, and I found 200+ more! If anyone else wants to help look for odd values in any columns or datasets, then below are version 1.0.0
of the Raw Garden lab result data.
Example usage:
import pandas as pd
# Read results.
df = pd.read_csv('https://cannlytics.page.link/?link=https://firebasestorage.googleapis.com/v0/b/cannlytics.appspot.com/o/data%252Flab_results%252Frawgarden%252Fresults.csv?alt%3Dmedia%26token%3Ddd868e72-edde-4278-9725-b33368a35d54')
# Look at all of the unique values.
unique_values = list(df['value'].unique())
errors = []
for value in unique_values:
try:
pd.to_numeric(value)
except:
errors.append(value)
print(errors)
Furthermore, the new utility function, create_hash
, found in cannlytics.utils.utils.py
, needs to be incorporated into CoADoc
's standardize
and perhaps save
/ aggregate
methods. For now, users can perform hashing for their data as follows.
from cannlytics.utils.utils import create_hash
import pandas as pd
# Read details.
df = pd.read_csv('https://cannlytics.page.link/?link=https://firebasestorage.googleapis.com/v0/b/cannlytics.appspot.com/o/data%252Flab_results%252Frawgarden%252Fdetails.csv?alt%3Dmedia%26token%3De5b5273a-049a-4092-98d7-90a62ef399a3')
# Create hashes for a given DataFrame of details.
df= df.where(pd.notnull(df), None)
df['results_hash'] = df['results'].apply(lambda x: create_hash(x))
df['sample_hash'] = df.loc[:, df.columns != 'sample_hash'].apply(
lambda x: create_hash(x.to_dict()),
axis=1,
)
datafile_hash = create_hash(df)
keeganskeate
changed pull request status to
merged