为什么dataframe会出现这种情况捏?刚刚开始学python,求解答。
他明明是对的上的呀
这种股票的数据,是解析了json字符串吗?
错位这种可能是你的代码有问题,不妨贴出部分代码看看
你自己设置index参数或者直接设置为空,不然它会拿第一列当index
【相关推荐】
new=pd.DataFrame({'name':'lisa',
'gender':'F',
'city':'北京',
'age':19,
'score':100},
index=[1]) # 自定义索引为:1 ,这里也可以不设置index
print(new)
print("-------在原数据框df1最后一行新增一行,用append方法------------")
df1=df1.append(new,ignore_index=True) # ignore_index=True,表示不按原来的索引,从0开始自动递增
print(df1)
import matplotlib
import matplotlib.pyplot as plt
from matplotlib import rcParams
matplotlib.use('pgf')
pgf_config={
"font.family":"serief",
"font.size":20,
"pgf.rcfonts":False,
"text.usetex":True,
"pgf.preamble":'\n'.join([
r"\usepackage{unicode-math}",
r"\setmainfont{times new roman}",
r"\usepackage{xeCJK}",
r"\xeCJKsetup{CJKmath=true}",
r"\setCJKmainfont{SimSun}",
]),
}
rcParams.update(pgf_config)