'BEEP structuring Error "No object to concatenate"
I have a made the csv file as requested by the beep library as folllows:
When I try to validtae the data from the cycler. It says validation has failed.
And I get the error:
File "C:\Users\concat.py", line 403, in __init__
raise ValueError("No objects to concatenate")
ValueError: No objects to concatenate
I know it means the data is missing but I dont see any. After doing print I see the data of the csv on print but it does not work.
class VLCyclerDatapath(BEEPDatapath):
"""An example of implementing a custom BEEPDatapath for your own cycler.
"""
COLUMN_MAPPING = {
"cycle_index": "cycle_index",
"step_index": "step_index",
"step_type":"step_type",
"step_time": "step_time",
"test_time": "test_time",
"current": "current",
"voltage": "voltage",
"charge_capacity": "charge_capacity",
"discharge_capacity": "discharge_capacity",
"charge_energy": "charge_energy",
"discharge_energy": "discharge_energy",
}
# Mapping of data types for BEEP columns
DATA_TYPES = {
"cycle_index": "int32",
"step_index": "int32",
"step_time": "float32",
"test_time": "float64",
"current": "float32",
"voltage": "float32",
"charge_capacity": "float64",
"discharge_capacity": "float64",
"charge_energy": "float64",
"discharge_energy": "float64",
}
@classmethod
def from_file(cls, filename, metadata_path=None):
# Load your file from the raw file filename
df = pd.read_csv(filename)
# data.rename(columns=cls.COLUMN_MAPPING, inplace=True)
for column, dtype in cls.DATA_TYPES.items():
if column in df:
if not df[column].isnull().values.any():
df[column] = df[column].astype(dtype)
# Read in metadata from a separate json file, for example
metadata = dict()
path = filename
paths = {
"raw": path,
"metadata": path + "_metadata"
}
print(df)
return cls(df, metadata, paths)
this_dir = os.path.dirname(os.path.abspath(__file__))
cycler_file = os.path.join(this_dir,("Trial_Writing.csv"))
print (cycler_file )
datapath = VLCyclerDatapath.from_file(cycler_file)
datapath.to_json_file("Trial_neware_data.json")
is_valid, msg = datapath.validate()
print("File is valid: ", is_valid)
datapath.structure()
Any suggestions?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
