-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnull_killer.py
More file actions
29 lines (24 loc) · 943 Bytes
/
Copy pathnull_killer.py
File metadata and controls
29 lines (24 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# import bibl
import pandas as pd
import csv
# Function read all data from csv(with delimiter '|') and clean up all ';' signs
def Opener(file):
df = pd.read_csv(file, delimiter='|', comment=';')
return df
# Function fill all "NaN" in columns which have 'float64' type
def fill_NaN(df):
for i in range(df.shape[1]):
if df.dtypes[i] == 'float64':
column = df.dtypes.index[i]
df[column].fillna(0, inplace=True)
return df
# Function fill all "NaN" in columns which have 'float64' type
def Loader(df):
df.to_csv(file, sep = '|', mode='w', index_label=False, index=False, header=True)
# names of files in your derectory. you can input as many names as you wish(in '' and seporated by ',')
files = [r'Path#1', r'Path#2']
# this is a cycle which take name from names array and execute funtions
for file in files:
step1 = Opener(file)
step2 = fill_NaN(step1)
Loader(step2)