Skip to content

Instantly share code, notes, and snippets.

View mebaysan's full-sized avatar
🏠
Working from home

Baysan mebaysan

🏠
Working from home
View GitHub Profile
@mebaysan
mebaysan / filter.py
Created November 17, 2020 12:05
Plotly Dash uygulamalarım için gelen parametrelere göre veri filtreleme fonksiyonu
import pandas as pd
DF = pd.read_csv('example.csv')
def data_filtrele(city, region, cat1, cat2, cat3, start_date, end_date):
filtered_df = DF
filtered_df = filtered_df[filtered_df['CITY'] == city] if city != 'Hepsi' else filtered_df
filtered_df = filtered_df[filtered_df['REGION'] == region] if region != 'Hepsi' else filtered_df
filtered_df = filtered_df[filtered_df['CATEGORY_NAME1'] == cat1] if cat1 != 'Hepsi' else filtered_df
filtered_df = filtered_df[filtered_df['CATEGORY_NAME2'] == cat2] if cat2 != 'Hepsi' else filtered_df
@mebaysan
mebaysan / doviz_converter.py
Created January 11, 2021 20:20
Döviz kurlarını çevirmek için kullandığım fonksiyon
DOVIZ_KURLAR = {
'Alış': {
'2015': {
'USD': 2.71,
'EUR': 3.01,
'GBP': 4.15,
},
'2016': {
'USD': 3.01,
'EUR': 3.33,
@mebaysan
mebaysan / sankey.py
Created January 28, 2021 15:27
Verilen Pathe Göre Otomatik Sankey Diagramı Verisi Hazırlayan Fonksiyon
import plotly.graph_objects as go
def get_sankey(data,path,value_col):
sankey_data = {
'label':[],
'source': [],
'target' : [],
'value' : []
}
counter = 0
@mebaysan
mebaysan / plotly-map-scripts.py
Last active February 13, 2021 10:11
Plotly Map Scriptlerim
import pandas as pd
import numpy as np
import plotly.graph_objects as go
import plotly.express as px
from plotly.subplots import make_subplots
import json
from unidecode import unidecode
with open('tr-cities-utf8.json','r') as file: # geojson dosyamızı açıyoruz
geojson = json.load(file)
@mebaysan
mebaysan / turkey-geojson.json
Created February 12, 2021 08:31
Türkiye İller GeoJson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mebaysan
mebaysan / pandas-remove-subset.py
Created February 12, 2021 09:06
Pandas alt küme silme işlemi örneği
############## Yöntem 1 ##############
istanbullar = sehirler[sehirler.sehir_ad.str.match('İstanbul*')]
mask = sehirler['sehir_ad'].isin(['İstanbul (Avrupa)', 'İstanbul (Anadolu)'])
sehirler = sehirler[~mask]
istanbullar.loc[:,'sehir_ad'] = 'İstanbul'
sehirler = pd.concat([sehirler,istanbullar])
############## Yöntem 2 ##############
istanbullar = sehirler.loc[sehirler['sehir_ad'].str.contains('İst*')]
sehirler = sehirler.drop(istanbullar.index)
@mebaysan
mebaysan / ilceler.json
Created February 12, 2021 12:43
Türkiye İlçeler JSON
[
{
"ilce_id": 1,
"il_plaka": 1,
"ilce_adi": "ALADAĞ(KARSANTI)",
"lat": 37.546379,
"lon": 35.402962,
"northeast_lat": 37.5552252,
"northeast_lon": 35.4189694,
"southwest_lat": 37.5375317,
@mebaysan
mebaysan / il.csv
Created February 12, 2021 12:44
Türkiye İller CSV
plaka il_adi lat lon northeast_lat northeast_lon southwest_lat southwest_lon
1 ADANA 37.00000000 35.32133330 37.07200400 35.46199500 36.93552300 35.17470600
2 ADIYAMAN 37.76416670 38.27616670 37.82566700 38.33546500 37.71708600 38.18818800
3 AFYONKARAHİSAR 38.76376000 30.54034000 38.80210500 30.61116700 38.71428900 30.44232000
4 AĞRI 39.72166670 43.05666670 39.74860500 43.08524100 39.68814400 43.00177800
5 AMASYA 40.65000000 35.83333330 40.67283400 35.85632100 40.63691100 35.78909100
6 ANKARA 39.92077000 32.85411000 40.10098100 33.02486600 39.72282100 32.49909700
7 ANTALYA 36.88414000 30.70563000 36.97517800 30.84095300 36.78586600 30.51609500
8 ARTVİN 41.18333330 41.81666670 41.20707800 41.85479900 41.15541500 41.77736100
9 AYDIN 37.84440000 27.84580000 37.87099700 27.88535500 37.81957300 27.79052200
@mebaysan
mebaysan / iller.json
Created February 12, 2021 12:44
Türkiye İller JSON
[
{
"plaka": 1,
"il_adi": "ADANA",
"lat": 37,
"lon": 35.3213333,
"northeast_lat": 37.072004,
"northeast_lon": 35.461995,
"southwest_lat": 36.935523,
"southwest_lon": 35.174706
@mebaysan
mebaysan / ilceler.csv
Created February 12, 2021 12:45
Türkiye İlçeler CSV
ilce_id il_plaka ilce_adi lat lon northeast_lat northeast_lon southwest_lat southwest_lon
1 1 ALADAĞ(KARSANTI) 37.54637900 35.40296200 37.55522520 35.41896940 37.53753170 35.38695460
2 1 CEYHAN 37.03170000 35.82275000 37.05572300 35.85007100 37.00624100 35.79596700
3 1 ÇUKUROVA 37.00000000 35.32133330 37.07200400 35.46199500 36.93552300 35.17470600
4 1 FEKE 37.81991810 35.91248350 37.82413110 35.92200700 37.81166900 35.90379300
5 1 İMAMOĞLU 37.25875100 35.67284000 37.27253900 35.67531600 37.24550600 35.64699500
6 1 KARAİSALI 37.25201000 35.06329000 37.26291800 35.07267000 37.24903100 35.05369700
7 1 KARATAŞ 36.56337600 35.38438800 36.58494800 35.40866200 36.55101900 35.36182800
8 1 KOZAN 37.45000000 35.80000000 37.48114000 35.84339500 37.43565900 35.77585300
9 1 POZANTI 37.42777780 34.87111110 37.43083110 34.87755900 37.41836900 34.85944100