import pandas as pd
data ={'Name':['Alice','Bob','Charlie'],'Age':[25,30,35]}
df = pd.DataFrame(data)print(df)
3.NumPy
功能简介:用于科学计算的库,提供多维数组和矩阵运算。
示例代码:
import numpy as np
arr = np.array([1,2,3,4,5])print(arr)
4.Matplotlib
功能简介:绘制数据可视化图表的库,支持各种图表类型。
示例代码:
import matplotlib.pyplot as plt
x =[1,2,3,4]
y =[10,15,13,18]
plt.plot(x, y)
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Simple Line Plot')
plt.show()
5.Scikit-learn
功能简介:机器学习库,包含多种常用的机器学习算法和工具。
示例代码:
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
iris = load_iris()
model = RandomForestClassifier()
model.fit(iris.data, iris.target)
6.TensorFlow
功能简介:深度学习框架,用于构建和训练神经网络模型。
示例代码:
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(10, activation='relu', input_shape=(4,)),
tf.keras.layers.Dense(3, activation='softmax')])
7.PyTorch
功能简介:另一个深度学习框架,提供动态计算图和GPU加速支持。
示例代码:
import torch
import torch.nn as nn
model = nn.Sequential(
nn.Linear(10,5),
nn.ReLU(),
nn.Linear(5,1))
8.Django
功能简介:用于构建Web应用的强大框架,提供ORM和开发便捷性。
示例代码:
from django.http import HttpResponse
defindex(request):return HttpResponse("Hello, world!")
9.Flask
功能简介:另一个流行的Web应用框架,轻量、灵活,适合快速开发。
示例代码:
from flask import Flask
app = Flask(__name__)@app.route('/')defhello_world():return'Hello, World!'
10.Beautiful Soup
功能简介:用于解析HTML和XML的库,方便地提取信息。
示例代码:
from bs4 import BeautifulSoup
html_doc ="<html><p>Hello, World!</p></html>"
soup = BeautifulSoup(html_doc,'html.parser')print(soup.p.text)
11.SQLAlchemy
功能简介:SQL工具包和ORM框架,用于数据库操作和管理。
示例代码:
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///:memory:')
Base = declarative_base()classUser(Base):
__tablename__ ='users'id= Column(Integer, primary_key=True)
name = Column(String)
12.Celery
功能简介:用于处理异步任务的分布式任务队列。
示例代码:
from celery import Celery
app = Celery('tasks', broker='pyamqp://guest@localhost//')@app.taskdefadd(x, y):return x + y
13.Twisted
功能简介:事件驱动的网络框架,用于构建高性能的异步应用。
示例代码:
from twisted.internet import reactor
defhello_world():print("Hello, World!")
reactor.stop()
reactor.callWhenRunning(hello_world)
reactor.run()