<jupyter_start><jupyter_text>---title: "Dataframe_to_csv"author: "Aavinash"date: 2020-08-12description: "-"type: technical_notedraft: false---<jupyter_code>import pandas as pd 

 
nme = ["aparna", "pankaj", "sudhir", "Geeku"] 
deg = ["MBA", "BCA", "M.Tech", "MBA"] 
scr = [90, 40, 80, 98] 

 
dict = {'name': nme, 'degree': deg, 'score': scr} 

df = pd.DataFrame(dict) 

 
df.to_csv('file1.csv') 


import pandas as pd 

 
nme = ["aparna", "pankaj", "sudhir", "Geeku"] 
deg = ["MBA", "BCA", "M.Tech", "MBA"] 
scr = [90, 40, 80, 98] 
 
dict = {'name': nme, 'degree': deg, 'score': scr} 
df = pd.DataFrame(dict) 

df.to_csv('file2.csv', header=False, index=False) 


import pandas as pd 


nme = ["aparna", "pankaj", "sudhir", "Geeku"] 
deg = ["MBA", "BCA", "M.Tech", "MBA"] 
scr = [90, 40, 80, 98] 

 
dict = {'name': nme, 'degree': deg, 'score': scr} 
df = pd.DataFrame(dict) 


df.to_csv(r'C:\Users\Admin\Home\pandas.csv', index=False) 

import pandas as pd 
import numpy as np 
users = {'Name': ['Amit', 'Cody', 'Drew'], 
	'Age': [20,21,25]} 
df = pd.DataFrame(users, columns=['Name','Age'])#create DataFrame 
print("Original DataFrame:") 
print(df) 
print('Data from Users.csv:') 
df.to_csv('Users.csv', sep='\t', index=False,header=True) 
new_df = pd.read_csv('Users.csv') 
print(new_df)<jupyter_output>Original DataFrame:
   Name  Age
0  Amit   20
1  Cody   21
2  Drew   25
Data from Users.csv:
  Name\tAge
0  Amit\t20
1  Cody\t21
2  Drew\t25
{'fraction_non_alphanumeric': 0.2066344160331721, 'fraction_numerical': 0.04008293020041465, 'mean_word_length': 4.134751773049645, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '29790', 'license': 'MIT', 'n_tokens_mistral': 699, 'n_tokens_neox': 625, 'n_words': 149, 'path': 'docs/python/pandas/Dataframe_to_csv.ipynb', 'repo_name': 'Aavinash1083/mlnotes', 'size': '1447'}