Language

Data Analysis · Lesson 35 of 56

Readdata

Source: 10-Data Analysis With Python/10.4-readdata.ipynb

Start here — no coding background needed

What you will learn

Load CSV/Excel into Python — on your machine with real files.

In simple words

In projects you read files from disk. Browser lessons show the idea only.

Spreadsheet-style work with code — for data jobs. Beginners: read concepts, run small examples.

Easy example — try this first

Easy example — run this first. Change values and press Run again.

Python

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference notes (from full bootcamp)

Optional — deeper detail for when you are ready

Reading Data From Different Sources

Reference example
Python

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
  employee_name            email  \
0         James  james@gmail.com   

                                         job_profile  
0  {'title1': 'Team Lead', 'title2': 'Sr. Develop...  

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
'{"employee_name":{"0":"James"},"email":{"0":"james@gmail.com"},"job_profile":{"0":{"title1":"Team Lead","title2":"Sr. Developer"}}}'

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
'{"0":{"employee_name":"James","email":"james@gmail.com","job_profile":{"title1":"Team Lead","title2":"Sr. Developer"}}}'

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
'[{"employee_name":"James","email":"james@gmail.com","job_profile":{"title1":"Team Lead","title2":"Sr. Developer"}}]'

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Example HCL
HCL
df=pd.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data",header=None)

Browser practice only — full example needs Python on your computer (files, Flask, threads, etc.).

Reference example
Python
Output
Expected (from notebook):
   0      1     2     3     4    5     6     7     8     9     10    11    12  \
0   1  14.23  1.71  2.43  15.6  127  2.80  3.06  0.28  2.29  5.64  1.04  3.92   
1   1  13.20  1.78  2.14  11.2  100  2.65  2.76  0.26  1.28  4.38  1.05  3.40   
2   1  13.16  2.36  2.67  18.6  101  2.80  3.24  0.30  2.81  5.68  1.03  3.17   
3   1  14.37  1.95  2.50  16.8  113  3.85  3.49  0.24  2.18  7.80  0.86  3.45   
4   1  13.24  2.59  2.87  21.0  118  2.80  2.69  0.39  1.82  4.32  1.04  2.93   

     13  
0  1065  
1  1050  
2  1185  
3  1480  
4   735  

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Example HCL
HCL
!pip install lxml

Browser practice only — full example needs Python on your computer (files, Flask, threads, etc.).

Example HCL
HCL
!pip install html5lib
!pip install beautifulsoup4

Browser practice only — full example needs Python on your computer (files, Flask, threads, etc.).

Reference example
Python

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
                             Bank NameBank       CityCity StateSt  CertCert  \
0    Republic First Bank dba Republic Bank   Philadelphia      PA     27332   
1                            Citizens Bank       Sac City      IA      8758   
2                 Heartland Tri-State Bank        Elkhart      KS     25851   
3                      First Republic Bank  San Francisco      CA     59017   
4                           Signature Bank       New York      NY     57053   
..                                     ...            ...     ...       ...   
564                     Superior Bank, FSB       Hinsdale      IL     32646   
565                    Malta National Bank          Malta      OH      6629   
566        First Alliance Bank & Trust Co.     Manchester      NH     34264   
567      National State Bank of Metropolis     Metropolis      IL      3815   
568                       Bank of Honolulu       Honolulu      HI     21029   

                 Acquiring InstitutionAI Closing DateClosing  FundFund  
0      Fulton Bank, National Association      April 26, 2024     10546  
1              Iowa Trust & Savings Bank    November 3, 2023     10545  
2                 Dream First Bank, N.A.       July 28, 2023     10544  
3              JPMorgan Chase Bank, N.A.         May 1, 2023     10543  
4                    Flagstar Bank, N.A.      March 12, 2023     10540  
..                                   ...                 ...       ...  
564                Superior Federal, FSB       July 27, 2001      6004  
565                    North Valley Bank         May 3, 2001      4648  
566  Southern New Hampshire Bank & Trust    February 2, 2001      4647  
567              Banterra Bank of Marion   December 14, 2000      4646  
568                   Bank of the Orient    October 13, 2000      4645  

[569 rows x 7 columns]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
     Mobile country code                                    Country ISO 3166  \
0                    289                                 A Abkhazia    GE-AB   
1                    412                                Afghanistan       AF   
2                    276                                    Albania       AL   
3                    603                                    Algeria       DZ   
4                    544  American Samoa (United States of America)       AS   
..                   ...                                        ...      ...   
247                  452                                    Vietnam       VN   
248                  543                        W Wallis and Futuna       WF   
249                  421                                    Y Yemen       YE   
250                  645                                   Z Zambia       ZM   
251                  648                                   Zimbabwe       ZW   

                                  Mobile network codes National MNC authority  \
0             List of mobile network codes in Abkhazia                    NaN   
1          List of mobile network codes in Afghanistan                    NaN   
2              List of mobile network codes in Albania                    NaN   
3              List of mobile network codes in Algeria                    NaN   
4       List of mobile network codes in American Samoa                    NaN   
..                                                 ...                    ...   
247        List of mobile network codes in the Vietnam                    NaN   
248  List of mobile network codes in Wallis and Futuna                    NaN   
249          List of mobile network codes in the Yemen                    NaN   
250             List of mobile network codes in Zambia                    NaN   
251           List of mobile network codes in Zimbabwe                    NaN   

                      Remarks  
0    MCC is not listed by ITU  
1                         NaN  
2                         NaN  
3                         NaN  
4                         NaN  
..                        ...  
247                       NaN  
248                       NaN  
249                       NaN  
250                       NaN  
251                       NaN  

[252 rows x 6 columns]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Example HCL
HCL
!pip install openpyxl

Browser practice only — full example needs Python on your computer (files, Flask, threads, etc.).

Example HCL
HCL
df_excel=pd.read_excel('data.xlsx')

Browser practice only — full example needs Python on your computer (files, Flask, threads, etc.).

Reference example
Python

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
    Name  Age
0  Anshul   32
1   Jack   34
2   John   31

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Practice test — try yourself

Write code, press Check. Wrong answer shows the correct code to copy & run.

You learned "Readdata". Use print() to show: Done: Readdata

Hint: Use one print() with the exact text.

Python