ziwangdeng.com
How to reshape and subset data with pandas functions? - AI Hobbyist
It is easy to change the layout, sort, reindex, rename, and subset table data using pandas commands. The simple code below shows you how to do this easily. The functions include melt(),pivot,sort_values,rename,sort_index,drop,filter,query,iloc,loc,iat,at and drop_duplicates. Prepare data #dowonload https://github.com/ziwangdeng/Data/blob/main/Vancouver_weather2010to2019_v00.csv import pandas as pd df=pd.read_csv('Vancouver_weather2010to2019_v00.csv') cols=df.columns df1=df[cols[:10]] df2=df[cols[10:]] ll=len(df) df3=df.head(5000) df4=df.tail(ll-5000) df.columns Index(['Unnamed: 0', 'Longitude (x)', 'Latitude ..Read more
admin