This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyType(type): | |
def __init__(cls, what, bases=None, dict=None): | |
print 'call myType.__init__()' | |
print "class name:"+what | |
print "class bases:"+str(bases) | |
print "class attributions:"+str(dict) | |
super(MyType,cls).__init__(what, bases, dict) | |
def __new__(cls, name, bases, attrs): | |
print "call MyType.__new__()" | |
return type.__new__(cls, name, bases, attrs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class num: | |
def __init__(self,v): | |
self.v=v | |
def double(self): | |
return self.v*2 | |
x=num(2) | |
bound=x.double |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data=pd.DataFrame([[2010,'auto'],[2010,'haha'],[2011,'haha'],[2012,'md']],columns=['year','type']) | |
data['typecnt']=np.ones(data.shape[0]) | |
data.groupby(['year','type'])['typecnt'].count() | |
输出 | |
year type | |
2010 auto 1 | |
haha 1 | |
2011 haha 1 | |
2012 md 1 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer