<jupyter_start><jupyter_text>---title: "Cut in pandas"author: "Charles"date: 2020-09-06description: "-"type: technical_notedraft: false---<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
l = np.arange(1, 20)
l
pd.cut(l, bins=3)
pd.cut(l, bins=3, labels=["small", "medium", "large"])
df = pd.DataFrame(pd.cut(l, bins=3, labels=["small", "medium", "large"]))
df
df.value_counts().plot(kind='barh')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19491525423728814, 'fraction_numerical': 0.029661016949152543, 'mean_word_length': 6.883333333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '233865', 'license': 'MIT', 'n_tokens_mistral': 203, 'n_tokens_neox': 188, 'n_words': 40, 'path': 'docs/python/Pandas/pd-cut.ipynb', 'repo_name': 'kamal2230/mltest', 'size': '472'}