我的代码-normalize


# coding: utf-8

# In[13]:

 

import pandas as pd
import numpy as np
import scipy as sp
from os import listdir
from os.path import isfile, join
from . import cleaning
mypath = r"D:\Users\sgg91044\Desktop\auto_data"
for j in range(20000):

onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
for file in onlyfiles:

*
*
*




time.sleep(10)
print("no files in the folder now, will check again")
j+1








#data=pd.read_csv(mypath + "\\" + file)
data=data.iloc[:,1:]
#data = data[data.ooc == 'N']
#data = data[data.oos == 'N']
data.drop(['ooc','oos'],axis=1,inplace=True)
data.drop(["waferid","Step","finishtime","parametername"],axis=1,inplace=True)
data.columns = ["eqpid","chamber","lot","wafer","param_name","recipe","data"]
pivoted = data.pivot_table(index=['eqpid','chamber','lot','wafer','recipe'],columns="param_name",values="data",aggfunc=np.sum)
pivoted.reset_index(inplace=True)
columns=["eqpid","chamber","lot","wafer","recipe","ETCM_PHA4","ETCM_PHB4","ETCM_PHC4","HELK_MAX.","HELK_MEAN","HELK_SD","LOWERCHM_PRESS","PBK4","RR13_MAX.","RR13_MEAN","RR23_MAX.","RR23_MEAN","THR3_MAX.","THR3_MAX._DIFF","THR3_MEAN","THR3_MEAN_DIFF","THR3_MEAN_SLOPE","THR3_SD"]
final = pd.DataFrame(columns = columns)
final = final.merge(pivoted,how="right").reindex_axis(columns, axis=1)
final=final.drop(columns=["eqpid","chamber","lot","wafer","recipe"])
final.to_csv(mypath + "\\" + "pivoted1_" + file)


# In[14]:


# numpy and pandas for data manipulation
import numpy as np
import pandas as pd

# sklearn preprocessing for dealing with categorical variables
from sklearn.preprocessing import LabelEncoder

# File system manangement
import os

# Suppress warnings
import warnings
warnings.filterwarnings('ignore')

# matplotlib and seaborn for plotting
import matplotlib.pyplot as plt
import seaborn as sns


# In[15]:


app_test = pd.read_csv(r'D:\Users\sgg91044\Desktop\more_parameter\more_parameter_pivot.csv')


# In[16]:


# Function to calculate missing values by column# Funct
def missing_values_table(app_test):
# Total missing values
mis_val = app_test.isnull().sum()

# Percentage of missing values
mis_val_percent = 100 * app_test.isnull().sum() / len(app_test)

# Make a table with the results
mis_val_table = pd.concat([mis_val, mis_val_percent], axis=1)

# Rename the columns
mis_val_table_ren_columns = mis_val_table.rename(
columns = {0 : 'Missing Values', 1 : '% of Total Values'})

# Sort the table by percentage of missing descending
mis_val_table_ren_columns = mis_val_table_ren_columns[
mis_val_table_ren_columns.iloc[:,1] != 0].sort_values('% of Total Values', ascending=False).round(1)

# Print some summary information
print ("Your selected dataframe has " + str(app_test.shape[1]) + " columns.\n"
"There are " + str(mis_val_table_ren_columns.shape[0]) + " columns that have missing values.")

# Return the dataframe with missing information
return mis_val_table_ren_columns


# In[17]:


# Missing values statistics
missing_values = missing_values_table(app_test)
missing_values


# In[ ]:


#!/usr/bin/env python
# -*- coding: utf8 -*-
# author: klchang
# Use sklearn.preprocessing.normalize function to normalize data.

from __future__ import print_function
import numpy as np
from sklearn.preprocessing import normalize


x = np.array([1, 2, 3, 4], dtype='float32').reshape(1,-1)

print("Before normalization: ", x)

options = ['l1', 'l2', 'max']
for opt in options:
norm_x = normalize(x, norm=opt)
print("After %s normalization: " % opt.capitalize(), norm_x)

 

posted on 2018-12-19 10:24  Aimee0207  阅读(120)  评论(0编辑  收藏  举报

导航