Skip to content
David Vegh edited this page Aug 15, 2022 · 4 revisions

Tutorial

write-condastat makes it easy to collect, filter and save conda statistics to csv files.

Visit our documentation site for code reference.

Initilaize a new WriteCondaStat class

In these examples we initilaize a WriteCondaStat class in order to collect statistics about pandas conda package.

Parameters:

  • package_name: name of the target conda package
  • outdir: path of the directory where the gathered data will be saved into csv files

Example - Initilaize without outdir

Because outdir is None the gathered statistics will be only printed to the console.

from writecondastat import WriteCondaStat

write_condastat = WriteCondaStat("pandas")

Example - Initilaize with outdir

Because outdir is not None the gathered statistics will be saved into csv files too.

from writecondastat import WriteCondaStat

write_condastat = WriteCondaStat("pandas", "stats/pandas")

Properties of the WriteCondaStat class

Properties:

  • outdir: path of the directory where the gathered data will be saved into csv files
  • date_period: grouping of the statistics
  • write_package_name: flag used to write the name of the package into a csv column
  • merge_stored_data: flag used to merge actual conda statistics with previously stored
  • fill_no_data: flag used to create empty lines with 0 download when data is not available

Example - Change outdir

outdir can be changed or set at anytime.

from writecondastat import WriteCondaStat

write_condastat = WriteCondaStat("pandas")

write_condastat.outdir = "stats/pandas"

Example - Change date_period

from writecondastat import WriteCondaStat

write_condastat = WriteCondaStat("pandas")

write_condastat.date_period= "month"

Example - Change write_package_name

from writecondastat import WriteCondaStat

write_condastat = WriteCondaStat("pandas")

write_condastat.write_package_name = True

Example - Change merge_stored_data

from writecondastat import WriteCondaStat

write_condastat = WriteCondaStat("pandas")

write_condastat.merge_stored_data = False

Example - Change fill_no_data

from writecondastat import WriteCondaStat

write_condastat = WriteCondaStat("pandas")

write_condastat.fill_no_data = False

Methods of the WriteCondaStat class

get_condastat

Parameters:

  • *data_source: type of the data source, for example conda-forge
  • start_date: start date of the statistics
  • end_date: end date of the statistics

Example - Get conda-forge statistics between 2022-03-01 and 2022-04-10

from writecondastat import WriteCondaStat, CondaStatDataSource

write_condastat = WriteCondaStat("pandas", "stats/pandas")

stats = write_condastat.get_condastat(
    CondaStatDataSource.CONDAFORGE,
    start_date="2022-03",
    end_date="2022-04-10"
)

write_condastat

Parameters:

  • *data_source: type of the data source, for example conda-forge
  • start_date: start date of the statistics
  • end_date: end date of the statistics
  • postfix: postfix of the csv file

Example - Write anaconda and conda-forge statistics between 2022-01-01 and 2022-03-31, grouped by month

from writecondastat import WriteCondaStat, CondaStatDataSource

write_condastat = WriteCondaStat("pandas", "stats/pandas")
write_condastat.date_period = "month"

write_condastat.write_condastat(
    CondaStatDataSource.CONDAFORGE,
    CondaStatDataSource.ANACONDA,
    start_date="2022",
    end_date="2022-03"
)

write_actual_condastat

Parameters:

  • *data_source: type of the data source, for example conda-forge
  • postfix: postfix of the csv file

Example - Write actual anaconda and conda-forge statistics

from writecondastat import WriteCondaStat, CondaStatDataSource

write_condastat = WriteCondaStat("pandas", "stats/pandas")

write_condastat.write_actual_condastat(
    CondaStatDataSource.CONDAFORGE,
    CondaStatDataSource.ANACONDA,
)