Ipython真的是个神奇的东西
b+=0.5
3.6*2-3.18
run python1
class Parents:
def hello(self):
print("hello")
p=Parents()
p.hello()
class child(Parents):
pass
c = chile()
c = child()
c.hello()
import torch as t
from torch import nn
nn.parameter??
a = np.zeros((2,3))
a(1,2)=1
a[1,2]=1
a = np.arange(1,10,1)
np.arange()??
np.arange??
a = np.arange(12)
a = np.arange(2,12)
a = np.linspace(1,11,50,1,1,np.float)
a = np.linspace(1,11,50,0,1,np.float)
for i in a:
print(i)
a = np.linspace(1,11,50,0,0,np.float)
a.retstep=1
for i in a:
print(i)
print('\n')
print np.version
np.version
np.__version__
a = np.ones((3,3),np.bool)
a = np.full((3,3),True,np.bool)
a = a[a%2==1]
a[a%2==1]=-1
b = np.where(a%2==1,-1)
b = np.where(a%2==1,1,-1)
b = np.where(a%2==1,-1,a)
b = np.where(a%2==1)
bb
b.dtype()
np.where??
a.nonzero??
np.nonzero()?
np.nonzero()??
np.nonzero??
a = np.arange(10).reshape((2,5))
a.nonzero()
a = np.arange(10)
b = np.repeat(1,10)
a.reshape(-1,2)
a=a.reshape(-1,2)
b = b.reshape(-1,2)
np.concatenate((a,b),0)
np.concatenate((a,b),1)
c=np.ones((5,4))
np.concatenate((a,b),1,c)
np.vstack([a,b])
[a,b]
np.vstack([1,2,3])
a[b]
np.max(a,b)
np.max(a)
run python1.py
path = 'iris.csv'
a = pd.read_csv(path)
a.shape[1]
a.shape.type
a.shape.dtype
a.shape.dtype()
a.shape.type()
a.shape
a.index
a[Species]
a.1
a(1)
a[1]
a.Species[1]
a.Species[0]
a.Species
a.Species.value_counts()
a.Species.value_counts()[1]
a.Species.value_counts().head(2)
a.Species.value_counts().head(0)
a.Species.value_counts().head(1)
a.Species.nunique()
a.Species.sum()
a.Sepal.Length
a[Sepal.Length]
a(Sepal.Length)
a('Sepal.Length')
a.'Sepal.Length'
a=pd.read_csv('iris.csv')
a.columns
a.columns=['U', 'SL', 'SW', 'PL',
'PW', 'Species']
a.head(10)
a.SL.sum()
a.SL.mean()
a.count()
b=a[['U','Species']]
b=a[['U','SL','SW']]
b.sort_values('SL')
c = b.sort_index('SL')
c = b.sort_vlues('SL')
c = b.sort_values('SL')
c = c.sort_values(['SL','SW'])
c.head(20)
c['U']
a['U']
a['U','SL']
a[['U','SL']]
clear c
b.head()
c.head()
reset c
c
a.head()
a.groupby('Species')
b=a.groupby('Species')
b.agg()
b.indices
c=b['setosa']
b['setosa']
b('setosa')
b.setosa
b.PL
b.PL.mean()
b.head(10)
b.info()
b.tail(10)
a.tail(10)
b.PL.describe()
b.mean()
b.median()
b.agg(['sum','mean','max','min'])
clear
ipython??
opython
ipython
python
math.c
a=1
del a
del
all
del all
data = sns.load_dataset('flights')
data['passengers'].groupby('year').sum
data[['year','passengers']].groupby('year').sum
data[['year','passengers']].groupby('year').sum()
data.groupby('year').sum()
year_group=data.groupby('year').sum()
a=plt.subplot()
a.plot(year_group.index,year_group['passenger'])
a.plot(year_group.index,year_group['passengers'])
pd.read_excel('1.xlxs')
a=pd.read('a')
a=pd.read('1')
a=pd.read_excel('1')
a=pd.read_excel('1.xlsx')
a.info()
import seaborn as sns
import pandas as pd
data = sns.load_dataset('iris')
data.columns=['SL','SW','PL','PW','SP']
data.info()
data['SS']=data['SL']*data['SW']
data['PS']=data['PL']*data['PW']
data.head(10)
plt.plot(data['SS'],data['PS'])
plt.scatter(data['SS'],data['PS'])
sp.constants
from scipy import constants as C
C.c
C.h
C.k
from scipy import io
a=np.array(10)
a=np.arrange(10)
a=np.arange(10)
a
io.savemat('a.mat',{'a':a})
b=io.loadmat('a.mat')
b
b['a']
w=1
q,w=1
q,w=1,2
q
w
scipy??
help(scipy)
import scipy as sp
sp??
%matplotlib
x = np.linspace(0,100,1000)
plt.plot(x,np.sin(x))
plt.plot(x,np.tan(x))
plt.style.use('classic')
plt.plot(x,np.cos(x*x))
plt.style.use('seaborn')
plt.style.use('ggplot')
style.available?
style.available
plt.style.available
plt.style.use('bmh')
plt.style.use('fast')
plt.style.use('fivethirtyeight')
plt.style.use('seaborn-white')
import matplotlib.pyplot as plyt
x = np.linspace(1,100,100)
plt.plot(x,cos(x))
plt.style
plt.style.use()
plt.style.use.__name__
plt.style.use.__str__()
_plt.style.use.__str__()
%ma
plt.drow()
plt.title('hahha')
fig,ax = plt.subplot(2,2)
%%matplotlib
%matplotlib
fig,ax = plt.subplot(2)
a,b,c=plt.subplot()
%matplotlib
plt.figure()
plt.subplot(2,1,1)
plt.plot(x,np,cos(x))
plt.subplot(2,1,2)
plt.plot(x,np.cos(x))
plt.title('ha')
import matplotlib as plt
x = np.linspace(1,10,100)
ax[0][0].plot(x,np.cos(x))
ax[0][1].title='No.2'
ax[0][0].title='No.1'
ax[0][0].title('No.1')
fig = plt.figure()
ax = fig.subplots(2,2)
ax[0][0].plot(x,x)
plt.title('No1')
reset
y
import matplotlib.pyplot as plt
import numpy as np
x=np.linspace(1,10,100)
plt.title('苏宇恒')
plt.title('su')
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)
....
....
plt.plot(x1,y1)
plt.xlabel("温度",fontproperties=font_set)
plt.ylabel("湿度",fontproperties=font_set)
plt.show()
%paste
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)
....
....
plt.plot(x1,y1)
plt.xlabel("温度",fontproperties=font_set)
plt.ylabel("湿度",fontproperties=font_set)
plt.show()
%paste
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)
plt.plot(x1,y1)
plt.xlabel("温度",fontproperties=font_set)
plt.ylabel("湿度",fontproperties=font_set)
plt.show()
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)
plt.plot(x,x)
pplt.title("苏宇恒")
plt.title("苏宇恒")
plt.title("苏宇恒",fontproperties=font_set)
plt.title("苏宇恒",fontproperties=font_set)
plt.title(u"苏宇恒")
fig, ax = plt.subplots()
ax
ax[0].plot(x,np.cos(x))
plt.show()
ax[1].plot(x,x)
fig, ax = plt.subplots(2,1)
ax[0].get_xlabel()
fig.set_label('1','b')
fig.set_label('1','b','c')
fig.set_label('1')
ax[0].set_label('a')
plt.draw()
ax[0].plot(x,x)
plt.legend()
ax[0].set_xlabel('x')
ax[0].set_title('hha')
ax[1].plot(x,np.cos(x),'o',color='green')
ax[1].plot(x,np.cos(x),'-o',color='green')
ax[1].plot(x,np.cos(x)*2,'-ok')
np.random.rand(50)
x = np.linspace(0,10,50)
y = np.sin(x)+0.8*np.random.rand(50)
plt.plot(x,y,'-Ok')
plt.plot(x,y,'-ok')
plt.errorbar(x,y,'-ok')
plt.errorbar(x,y,yerr=0.8,fmt='.k')
plt.errorbar(x,y,yerr=0.8,fmt='ok')
plt.errorbar(x,y,yerr=0.8,fmt='og')
plt.errorbar(x,y,yerr=0.8,fmt='or')
plt.errorbar(x,y,yerr=0.8,fmt='oy')
plt.errorbar(x,y,yerr=0.8,fmt='ob')
def f(x,y):
return np.sin(x)**10+np.cos(10+y*x)*np.cos(x)
x = np.linspace(0,5,50)
y = np.linspace(0,5,40)
X,Y = np.meshgrid(x,y)
Z=f(x,y)
Z=f(X,Y)
plt.contour(X,Y,Z,colors='black')
x
X
%hist