TypeError: expected str, bytes or os.PathLik when I save a excel file

Viewed 25

This is my code and try to save the output. But I see this error:

Traceback (most recent call last):
File "/home/jovyan/./main.py", line 26, in <module>
 input_df = pd.read_csv(os.path.join(input_path, filename))
File "/srv/conda/envs/notebook/lib/python3.9/posixpath.py", line 76, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLik

............

input_path = os.environ.get('DATA_104_PATH') + '/test_data'

output_path = '/output'

class TimeSeriesAnomalyDetector:

def call(self, df):

...

return df

anomaly_detector = TimeSeriesAnomalyDetector()

if name == 'main':

  for filename in os.listdir(input_path):
    if filename.endswith(".csv"):
      input_df = pd.read_csv(os.path.join(str(input_path), filename))
      
      
      input_df['timestamp']  = scaler.fit_transform(input_df[['timestamp']])


      print(filename, len(input_df))

      result = anomaly_detector(input_df)

      result.to_csv(os.path.join(str(output_path), filename))   
0 Answers
Related