Py学习  »  Python

Python日志记录不记录pd.info()

loadbox • 6 年前 • 2237 次点击  
import logging
import pandas as pd

logger = logging.getLogger('train')
logger.setLevel(logging.DEBUG)

# Data
data = {'Name': ['Tom', 'nick', 'krish', 'jack'], 'Age': [20, 21, 19, 18]}

# Create DataFrame
df = pd.DataFrame(data)

logger.info(type(df))
logger.info(df.info())
.
.
.
<other_processes>
.

上述代码输出:

<class 'pandas.core.frame.DataFrame'>
None
.
.
.

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4 entries, 0 to 3
Data columns (total 2 columns):
Name    4 non-null object
Age     4 non-null int64
dtypes: int64(1), object(1)
memory usage: 144.0+ bytes

为什么要打印 None 当我尝试记录df.info()时?如何在日志中的指定位置获取df.info()?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/57338
文章 [ 1 ]  |  最新文章 6 年前