Skip to content

Instantly share code, notes, and snippets.

View lakshay-arora's full-sized avatar
🇮🇳

Lakshay lakshay-arora

🇮🇳
  • Walmart
  • Bengaluru
View GitHub Profile
import pandas as pd
import gmplot
data = pd.read_csv('3D_spatial_network.csv')
data.head()
# latitude and longitude list
latitude_list = data['LATITUDE']
longitude_list = data['LONGITUDE']
# center co-ordinates of the map
gmap = gmplot.GoogleMapPlotter( 56.730876,9.349849,9)
# plot the co-ordinates on the google map
gmap.scatter( latitude_list, longitude_list, '# FF0000', size = 40, marker = True)
import pandas as pd
import category_encoders as ce
# create a Dataframe
data = pd.DataFrame({ 'gender' : ['Male', 'Female', 'Male', 'Female', 'Female'],
'class' : ['A','B','C','D','A'],
'city' : ['Delhi','Gurugram','Delhi','Delhi','Gurugram'] })
data.head()
# One Hot Encoding
# create an object of the One Hot Encoder
ce_OHE = ce.OneHotEncoder(cols=['gender','city'])
# transform the data
data = ce_OHE.fit_transform(data)
data.head()
import pandas as pd
from tqdm._tqdm_notebook import tqdm_notebook
from pysal.lib.cg import harcdist
tqdm_notebook.pandas()
data = pd.read_csv('3D_spatial_network.csv')
data.head()
# calculate the distance of each data point from # (Latitude, Longitude) = (58.4442, 9.3722)
def calculate_distance(x):
return harcdist((x['LATITUDE'],x['LONGITUDE']),(58.4442, 9.3722))
data['DISTANCE'] = data.progress_apply(calculate_distance,axis=1)
import pandas as pd
import pandas_profiling
# read the dataset
data = pd.read_csv('add-your-data-here')
pandas_profiling.ProfileReport(data)
import pandas as pd
data = pd.read_excel('sales-data.xlsx')
data.head()
data['date'] = pd.to_datetime(data['date'])
data.set_index('date').groupby('name')["ext price"].resample("M").sum()