Posts

import and save csv files

  car = pd.read_csv ( r'C:\Users\MR.D\Desktop\minor project\model\data.csv' ) car.to_csv( 'cleaned_data1.csv' )

convert csv file to html and vice versa or to any other files

import pandas as pd data=pd.read_csv( 'location' , index_col = 0 ) data.to_html( 'data.html' )

pandas operations

   import  pandas  as  pd dict={ 'day' :[ 1 , 2 , 3 , 4 , 5 , 6 ], 'visitors' :[ 1000 , 2000 , 3000 , 4000 , 5000 , 6000 ], 'bounce_rate' :[ 20 , 30 , 40 , 50 , 60 , 70 ]} df=pd.DataFrame(dict) print (df) #operations on pandas #1. slicing of data #eg1. printing 1sst two rows of data only a=df.head( 2 ) print (a) #eg2. printing last 2 rows of data b=df.tail( 2 ) print (b) #2. merging of datasets # while merging same table of two different data it will seperate the table individually mendioning x and y data1={ "city" :[ 'kathmandu' , 'biratnagar' , 'bhairahawa' , 'pokhara' ], "humidity" :[ 1200 , 1300 , 1400 , 1500 ], "saturation" :[ 1 , 2 , 3 , 4 ]} df1=pd.DataFrame(data1) print (df1) data2={ "city" :[ 'kathmandu' , 'biratnagar' , 'bhairahawa' , 'pokhara' ], "humidity" :[ 1400 , 400 , 200 , 800 ], "saturation" :[ 5 , 6 , 7 , 8 ]} df2...