To feed data to our programs, we need to understand how to input data. Since the data courses vary, we introduce several ways to input data, such as from clipboard, Yahoo! Finance, an external text or CSV file, a web page, and a MATLAB dataset.
In our everyday lives, we use Notepad, Microsoft Word, or Excel to input data. One of the widely used functionalities is copy and paste. The
pd.read_clipboard() function contained in
Pandas mimics this operation. For example, we type the following contents on Notepad:
x y 1 2 3 4 5 6
Then, highlight these entries, right-click on it, copy and paste in the Python console, and run the following two lines:
>>>import pandas as pd >>>data=pd.read_clipboard() ...