Data input is often much underestimated - but
something which you will have to do very often. In my
experience, the most flexible way to handle most data input is
to use df = pd.read_csv from the Python package Pandas, and then
extract the numpy-values with df.values.
For more information, have a look at
cd <data_dir>file_name by typingfile_name = '2022file_name =
'2022_antarctic_mass_loss.csv' to file_name = '2022_antarctic_mass_loss.csv' np.loadtxt, taking into
consideration that the first 31 lines are a header. Note:
In IPython you can get help on a command by typing a
? at the end of the command. For example, you can
get help on np.loadtxt by typing
np.loadtxt? .
matplotlib.pyplot, which is commonly
abbreviated as plt.)cd to a different folder.data_dir = <...>
import os
in_file = os.path.joint(data_dir, file_name)
data = np.loadtxt(in_file, ....)
pandas
is the best tool. pandas has its background in data
bases, and as a result uses a different syntax than
numpy. The most common data element in
pandas is a DataFrame.
import pandas as pd
df = pd.read_csv(in_file, skiprows=31, delim_whitespace=True, header=None)
type(df)
type(data)
df.head() and df.tail().df.columns data_values = df.values .py-file) that
preforms the steps described above, for pandas DataFrames. The
only step that you really need to change is that
you have to terminate a plot with plt.show().
Note: In programs you can NOT use cd to
change directories, but have to use os.chdir( ... )!