0
点赞
收藏
分享

微信扫一扫

Pandas数据读取-自我总结

前程有光 2021-09-28 阅读 93
import pandas as pd

df = pd.read_csv(r"D:\node\nd\Pandas_study\pandas_test\beijing_tianqi_2018.csv")

df.set_index("ymd",inplace=True)
df.loc[:,"bWendu"] =df["bWendu"].str.replace("℃","").astype("int32")
df.loc[:,"yWendu"] =df["yWendu"].str.replace("℃","").astype("int32")
print(df.head())

#如果取列名,参数为true即可,条件表达式取值
print(df.loc[df["bWendu"]==3])
print(df["bWendu"] == 3)

#取整列值
print(df.loc[:,["bWendu","yWendu"]].head())

#取整行值
print(df.loc[["2018-01-01","2018-01-05"]]) #Dataframe
print(df.loc["2018-01-01"]) #Serise
举报

相关推荐

0 条评论