>>> import seaborn as sns
>>> sns.get_datasets_names()
['anagrams',
'anscombe',
'attention',
'brain_networks',
'car_crashes',
'diamonds',
'dots',
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please note the results for larger list can be different | |
import numpy as np | |
# making a list, a dict, and an array | |
list_a = list(np.asarray(np.linspace(0,9,10)).astype(int)) # working with int | |
array_a = np.array(list_a) | |
dict_a = {x: x for x in list_a} | |
from operator import add as opadd | |
%timeit -r5 list_c = list(map(opadd, list_a, list_a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""See https://stackoverflow.com/questions/3278077/difference-between-getattr-v | |
s-getattribute : | |
__getattr__ is only invoked if the attribute wasn't found the usual ways. | |
It's good for implementing a fallback for missing attributes, and is probab | |
ly the one of two you want. | |
""" | |
import numpy as np | |
class foo(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title: Pelican setup gist | |
Description: What are the steps to get blog like this one up and running? | |
You can find this as a gist [here](https://gist.github.com/mocquin/6b79794f2edb87fc671f28f0d2aeb6c1) | |
For this, you'll need basic knowledge of pip, terminal, virtualenv, python, git, and github. | |
Disclaimer : this is not a tutorial, this a quick recipe that worked for me. I voluntarly skip most of the explication part. | |
``` |
>>> iris_df = sns.load_dataset("iris")
>>> iris_df.head()
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
>>> sns.load_dataset(
"iris",
data_home="/Users/mocquin/documents/datasets"
)
>>> sns.get_data_home()
'/Users/mocquin/seaborn-data'
sns.load_dataset(name, cache=True, data_home=None, **kws)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class Physical(): | |
def __init__(self, value, unit=""): | |
self.value = value # store the numerical value as a plain numpy array | |
self.unit = unit | |
def __repr__(self): | |
return f"<Physical:({self.value}, {self.unit})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class Physical(): | |
def __init__(self, value, unit=""): | |
self.value = value | |
self.unit = unit | |
def __repr__(self): | |
return f"<Physical:({self.value}, {self.unit})" |
OlderNewer