擅长:python、mysql、java
<p>{padningham很难使用@ccungham来创建:</p>
<pre><code>import functools
def assert_index_datetime(f):
@functools.wraps(f)
def wrapper(df):
assert df.index.dtype == pd.to_datetime(['2013']).dtype
return f(df)
return wrapper
@assert_index_datetime
def fn(df):
pass
df = pd.DataFrame({'a': [1]}, index=pd.to_datetime(['2013']))
fn(df)
</code></pre>