Import Files with Pandas in Python

Import files in python

February 23, 2021 · 4 mins read

Import Files with Pandas

import pandas as pd
import os
stats = pd.read_csv('D:\\OneDrive - office365hubs.com\\.Python for data science\\Demographic-Data.csv')
stats
Country Name Country Code Birth rate Internet users Income Group
0 Aruba ABW 10.244 78.9 High income
1 Afghanistan AFG 35.253 5.9 Low income
2 Angola AGO 45.985 19.1 Upper middle income
3 Albania ALB 12.877 57.2 Upper middle income
4 United Arab Emirates ARE 11.044 88.0 High income
... ... ... ... ... ...
190 Yemen, Rep. YEM 32.947 20.0 Lower middle income
191 South Africa ZAF 20.850 46.5 Upper middle income
192 Congo, Dem. Rep. COD 42.394 2.2 Low income
193 Zambia ZMB 40.471 15.4 Lower middle income
194 Zimbabwe ZWE 35.715 18.5 Low income

195 rows × 5 columns

os.chdir('D:\\OneDrive - office365hubs.com\\.Python for data science')
print(os.getcwd())
D:\OneDrive - office365hubs.com\.Python for data science
stats
Country Name Country Code Birth rate Internet users Income Group
0 Aruba ABW 10.244 78.9 High income
1 Afghanistan AFG 35.253 5.9 Low income
2 Angola AGO 45.985 19.1 Upper middle income
3 Albania ALB 12.877 57.2 Upper middle income
4 United Arab Emirates ARE 11.044 88.0 High income
... ... ... ... ... ...
190 Yemen, Rep. YEM 32.947 20.0 Lower middle income
191 South Africa ZAF 20.850 46.5 Upper middle income
192 Congo, Dem. Rep. COD 42.394 2.2 Low income
193 Zambia ZMB 40.471 15.4 Lower middle income
194 Zimbabwe ZWE 35.715 18.5 Low income

195 rows × 5 columns

stats2 = pd.read_csv('Demographic-Data.csv')
stats2
Country Name Country Code Birth rate Internet users Income Group
0 Aruba ABW 10.244 78.9 High income
1 Afghanistan AFG 35.253 5.9 Low income
2 Angola AGO 45.985 19.1 Upper middle income
3 Albania ALB 12.877 57.2 Upper middle income
4 United Arab Emirates ARE 11.044 88.0 High income
... ... ... ... ... ...
190 Yemen, Rep. YEM 32.947 20.0 Lower middle income
191 South Africa ZAF 20.850 46.5 Upper middle income
192 Congo, Dem. Rep. COD 42.394 2.2 Low income
193 Zambia ZMB 40.471 15.4 Lower middle income
194 Zimbabwe ZWE 35.715 18.5 Low income

195 rows × 5 columns