pip install -r .\requirements.txt
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
# Save ndarray to disk
arr = np.arange(10)
np.save('saved_npy_array',arr)
arr2= np.load('saved_npy_array.npy')
# Read csv using pandas
result = pd.read_csv('examples/ex6.csv')
# Draw 2D chart
import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(10))
# Plot with pandas
s = pd.Series(np.random.randn(10).cumsum(), index=np.arange(0, 100, 10))
s.plot()
Executes below script in ipython terminal
import numpy as np
import pandas as pd
import json
db = json.load(open('datasets/usda_food/database.json'))
len(db)
db[0]
db[0].keys()
db[0]['nutrients']
db[0]['nutrients'][:7]
type(db[0]['nutrients'])
from pandas import DataFrame
nutrients = DataFrame(db[0]['nutrients'])
nutrients[0:7]
# value_counts 查看营养类别的分布情况
pd.value_counts(nutrients.group)
# 汇总所有营养数据做分析
nutrients = []
for rec in db:
fnuts = DataFrame(rec['nutrients'])
fnuts['id']= rec['id']
nutrients.append(fnuts)
nutrients = pd.concat(nutrients, ignore_index=True)
nutrients = nutrients.drop_duplicates()
Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of formats and interactive environments across platforms.
pip install pyecharts
python ./pyecharts-demo.py