0

I have taken some large datasets from csv files, stacked them, and am trying to replace missing and negative values in my final column, with 0's. I believe that I have achieved with the missing values, however, I am unsure with negative values. Currently my code is as follows (I intend to do further plotting later on):

from __future__ import division
from pandas import Series, DataFrame
import pandas as pd
import numpy as np
import os
import matplotlib.pyplot as plt

# Creation of main and root directory
main_dir = "/Users/Test/Desktop/Data/"
root = main_dir + "Practice/section_1"

# Pathing
paths = [os.path.join(root,v) for v in os.listdir(root) if v.startswith("gas_long_redux_")]


# Importing and Stacking
missing = [' ', 'NA', '.', 'null']

df = pd.concat([pd.read_csv(v, names = ['ID', 'date_cer', 'kwh']) for v in paths],
    ignore_index = True)

## replace missing values with 0
df = df.fillna(0)

Does anyone have any suggestions for replacing negative values, or resources for me to look upon? Thanks in advance.

YXD
  • 31,741
  • 15
  • 75
  • 115
Rivers31334
  • 644
  • 1
  • 12
  • 30

0 Answers0