program.py
import matplotlib.pyplot as plt
import pandas as pd
plt.style.use(‘fivethirtyeight’)
‘’‘matplotlib.pyplot.hist(x, bins=None, range=None, density=False,
weights=None, cumulative=False, bottom=None, histtype=‘bar’,
align=‘mid’, orientation=‘vertical’, rwidth=None, log=False,
color=None, label=None, stacked=False, *, data=None, **kwargs) ‘’’
‘’’
ages = [18, 19, 21, 25, 26, 26, 30, 32, 38, 45, 55]
bins = [10, 20, 30, 40, 50, 60]
plt.hist(ages, bins=bins, edgecolor=‘black’)
‘’’
data = pd.read_csv(‘data.csv’)
print(data)
ids = [‘Responder_id’]
ages = data[‘Age’]
bins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
plt.hist(ages, bins=bins, edgecolor=‘black’, log=True)
median_age = 29
color = ‘#fc4f30’
plt.axvline(median_age, color=color, label=‘29 Age Median’)
plt.axvline(18, color=color, label=‘18 Age Median’)
plt.title(‘Histograms’)
plt.xlabel(‘Ages’)
plt.legend()
plt.tight_layout()
plt.show()
Terminus Python.sublime-build
{
“target”: “terminus_exec”,
“cancel”: “terminus_cancel_build”,
“focus”: true,
“shell_cmd”: “python -u “$file””,
“file_regex”: “^[ ]File "(…?)”, line ([0-9]*)",
“selector”: “source.python”,
"env": {"PYTHONIOENCODING": "utf-8"},
"variants":
[
{
"name": "Syntax Check",
"shell_cmd": "python -m py_compile \"${file}\"",
}
]
}
Error
Traceback (most recent call last):
File “F:\Python\Matplotlib\Histograms\Histograms_csv.py”, line 17, in
data = pd.read_csv(‘data.csv’)
File “C:\Users\Akashdip Hazra\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py”, line 686, in read_csv
return _read(filepath_or_buffer, kwds)
File “C:\Users\Akashdip Hazra\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py”, line 452, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File “C:\Users\Akashdip Hazra\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py”, line 936, in init
self._make_engine(self.engine)
File “C:\Users\Akashdip Hazra\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py”, line 1168, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File “C:\Users\Akashdip Hazra\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py”, line 1998, in init
self._reader = parsers.TextReader(src, **kwds)
File “pandas_libs\parsers.pyx”, line 382, in pandas._libs.parsers.TextReader.cinit
File “pandas_libs\parsers.pyx”, line 674, in pandas._libs.parsers.TextReader._setup_parser_source
FileNotFoundError: [Errno 2] No such file or directory: ‘data.csv’
[Finished in 2.16s with exit code 1]