Coder Social home page Coder Social logo

python-data-analysis-basic's Introduction

Python Data Analysis Learning Path

pip install -r .\requirements.txt

Pandas

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()

Example: USDA Food Composition Databases

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

Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of formats and interactive environments across platforms.

数据可视化: Echarts

pip install pyecharts
python ./pyecharts-demo.py

python-data-analysis-basic's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.