title: How To ' Write To New .CSV File' or "Save As New .CSV File' In python
body: <p>I have a CSV file, I want to apply One hot encoding, then save the new dataframe(dataset) as a new CSV file. But when the new file is saved, it only writes 5 Rows of dummies and all rows of original dataset! </p>
  
  <p>I just want to save all rows and columns in the new file.csv, the final shape of the dataset is <code>(237124, 417)</code>.</p>
  
  <p>my code contain: </p>
  
  <pre><code>import numpy as np 
  import pandas as pd
  from sklearn.preprocessing import OneHotEncoder 
  from sklearn.preprocessing import LabelEncoder 
  import csv
  
  dataset=pd.read_csv("C:/Users/User/Desktop/data.csv",encoding='cp1252')
  dataset.shape
  #output: (237124, 37)
  
  dummies = pd.get_dummies(dataset, columns=["name","mark",....... ]).head()
  dummies.shape
  #output : (5, 380)
  
  dataset = pd.concat([dataset, dummies], axis=1)
  dataset.shape
  #output: (237124, 417)
  # i want this shape(original+dummies)
  
  dataset.to_csv('OneHotEncodnig.csv', index=False)
  </code></pre>