Skip to content

Instantly share code, notes, and snippets.

View maria-aguilera's full-sized avatar

Maria Aguilera García maria-aguilera

View GitHub Profile
@RPChinhara
RPChinhara / xml_to_json.py
Last active July 31, 2024 10:31
XML to JSON
import xml.etree.ElementTree as ET
import json
def parse_element(element, namespace, indent=""):
result = {}
if element.attrib:
result['attributes'] = element.attrib
if element.text and element.text.strip():
@maria-aguilera
maria-aguilera / mpl_pandas_plot_tools.py
Created November 16, 2022 16:02 — forked from vignesh-saptarishi/mpl_pandas_plot_tools.py
Utility functions for visualization using pandas dataframes and matplotlib
import numpy
import pandas
import matplotlib.pyplot as plt
import seaborn as sns
from ggplot import *
plt.style.use('ggplot')
def get_histogram_xy(data, bins=10):
"""Returns x,y coordinates for Histogram data.
@maria-aguilera
maria-aguilera / automobile.py
Created November 16, 2022 15:59 — forked from ethen8181/automobile.py
What appears to be the three or four most important car attributes for predicting a car’s price? (http://archive.ics.uci.edu/ml/datasets/Automobile)
"""
python3
numpy>=1.12.0
pandas>=0.19.2
matplotlib>=2.0.0
sklearn>=0.18
xgboost>=0.6
sortedcontainers>=1.5.7
"""
def plot_categorical_variables_pie(data, column_name, plot_defaulter = True, hole = 0):
'''
Function to plot categorical variables Pie Plots
Inputs:
data: DataFrame
The DataFrame from which to plot
column_name: str
Column's name whose distribution is to be plotted
plot_defaulter: bool
@maria-aguilera
maria-aguilera / kaggle.py
Created November 16, 2022 15:14 — forked from AdityaSoni19031997/kaggle.py
Kaggle Helper Scripts
import seaborn as sns
from sklearn import preprocessing, ensemble
from scipy.stats import kendalltau
import pandas as pd
import random
#todo change module name
from tqdm import tqdm
import numpy as np
import pandas as pd
@maria-aguilera
maria-aguilera / plot_categorical.py
Created November 16, 2022 15:12 — forked from netsatsawat/plot_categorical.py
Function to plot categorical data
def plot_categorical(df: pd.DataFrame , col:str):
"""
Function to plot the categorical data on piechart using Plotly
@Args:
df: pandas data frame
col: A string column name within pandas data frame to plot
Return:
No object return, only visualization
"""
# Function to print digits on top of Barplot
def show_values(axs, orient="v", space=.01):
def _single(ax):
if orient == "v":
for p in ax.patches:
_x = p.get_x() + p.get_width() / 2
_y = p.get_y() + p.get_height() + (p.get_height()*0.01)
value = '{:.2f}'.format(p.get_height())
ax.text(_x, _y, value, ha="center")
elif orient == "h":
res_dim = 1024
if __name__ == "__main__":
"""loading the data,
reading the file annotations,
appending the tabular coordinates to formulate a dataframe
"""
df_org = pd.DataFrame()
directory = '/content/drive/MyDrive/data_cs2'
final_col_directory = '/content/drive/MyDrive/cs2_col'
@ksv-muralidhar
ksv-muralidhar / outlier_detect_1.py
Created February 16, 2021 03:24
outlier detection
from sklearn.datasets import load_wine
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
data = pd.DataFrame(load_wine()["data"],columns=load_wine()["feature_names"])
data.head()
#Canvas
fig,ax = plt.subplots(1,1,figsize=(13,7.5),dpi=100)
#Chart
ax.plot(x,y,color=palette["primary_chart"],
zorder=2)
ax.scatter(x,y,color=palette["background"],
edgecolor=palette["primary"],
s=90,
zorder=3)