Skip to content

Latest commit

 

History

History

2_DataTable

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

2. DataTable

Ex00

Pandas usage.

  • pd.read_csv(path) loads csv from given path.

Ex01

pandas to manage data, matplotlib to display graphs.

Pandas:

  • Indexing and selecting data
  • Selecting rows from Pandas DataFrame
  • country_data = data[data["country"] == country] select rows from a DataFrame using a boolean vector the same length as the DataFrame’s index. Its possible to use operators like >, <, etc.
  • country_data.columns gets list of all columns.
  • country_data.values gets list of all values.

Matplot:

  • Matplot
  • plt.plot(columns, values) sets points.
  • plt.title("") sets graph title.
  • plt.xlabel("") sets x axe label. Same with ylabel.
  • plt.xticks(years[::40], ["tag1", "tag2"]) sets ticks from list. Its possible to give a second list with the tags to show. Same with yticks.
  • plt.show() shows graph.

Other graph libraries: Plotly express

Ex02

Similar to ex01 with two plots and legend.

  • Data needs to be normalized, as matplot does not understand 10B, 2M, 1k format.
  • plt.legend(list(arg), loc="lower right") puts a legend.

Ex03

Similar with scatter graph.

  • plt.scatter(year_income_per_person, year_life_expectancy) creates scatter.
  • plt.xscale('log') puts logarithmic scale.