【发布时间】:2018-08-04 03:36:59
【问题描述】:
我的 .txt 文件中有如下数据:
029070 ***** 190101010600 270 36 OVC ** 0.0 ** **
我想从第 3 列中提取 190101,我得到 AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandasbelow is my python pandas。下面是我的代码
import pandas as pd
import numpy as np
import re
data = pd.read_csv('dummy.txt', sep=" ", low_memory=False, header=None)
data.columns = ["a", "b", "c","d","e","f","g","h","i","j"]
print(data.c.str[0:6])
【问题讨论】: