top of page

Python - Basics - Pandas


import pandas as pd


pwd


# read file from file system


df=pd.read_csv('bevolkerung.csv’)


# read file from github


from pandas import Series, DataFrame

url1 = 'https://raw.githubusercontent.com/spribylova/Data/master/Assets.csv'

assets = pd.read_csv(url1,index_col=0)

url2 = 'https://raw.githubusercontent.com/spribylova/Data/master/Firmen.csv'

firmen = pd.read_csv(url2,index_col=0)

banks = pd.merge(assets, firmen, on='IN')

banks.describe()

banks


import matplotlib.pyplot as plt


import numpy as np


# summary statistics to describe numeric fields of uploaded file


# data is file are for 2 years /January 1998 - December 1999/ , provided is number of inhaitants in Zurich, Month, Day, Gender, Age group, Origin, District name, District code, number of inhabitants


df.describe()


df.groupby(['StichtagDatJahr', 'KreisCd'])['AnzBestWir'].sum().reset_index()


df3=df.groupby(['KreisCd'])['AnzBestWir'].sum().reset_index()


df3.sort_values(by=['KreisCd’])


df3.plot.bar(x="KreisCd", y="AnzBestWir”);


# Chart the ratio of foreigners within the total population in Kreis 2 over time # vorbereitet filter fur Kreis 2


filt2 = df2['KreisCd'] == 2


df2=df.groupby(['KreisCd', 'HerkunftLang'])['AnzBestWir'].sum().reset_index()


df2.where(filt2, inplace = True)


# using dropna() function


df4=df2.dropna(how = 'all’)


df4


# using dropna() function


df2.dropna(how = 'all’)








17 views0 comments

Recent Posts

See All

Comments


bottom of page