df=pd.DataFrame({"A":1,"B":pd.Timestamp("20170301","C":pd.Series(1,index=list(range(4)),dtype="float32"),"D":np.array([3]*4,dtype="float32"),"E":pd.Categorical(["police","student","teacher","doctor"])}) ^
SyntaxError: invalid syntax
"C":pd.Series(1,index=list(range(4)),dtype="float32"),一段显示“variables annotation cannot be combined with tuple unpacking”
建议在pycharm里编写,方便debug
很明显你的这段代码是在这里有错:
B":pd.Timestamp("20170301","C":
应该修改为:
B":pd.Timestamp("20170301"),"C":
建议用pycharm编写,方便debug
这一段正确的代码应该是这样的:
df = pd.DataFrame({ "A": 1, "B": pd.Timestamp("20170301"), "C": pd.Series(1, index=list(range(4)), dtype="float"), "D": np.array([3] * 4, dtype="float32"), "E": pd.Categorical(["police", "student", "teacher", "doctor"])})