dcdcpy (deprecated)

This package has been deprecated, please see the announcement for alternatives.

DataCamp provides packages in both R and Python that allow you to easily use the Data Connector.

The python package is called dcdcpy. This package contains utilities to work with DataCamp Data Connector. It is designed to be used by administrators and managers of DataCamp groups. Some prior experience of writing reports with Python is recommended.

Before you can get started with using dcdcpy, you need to make sure your credentials are set up properly. How to do this is explained in the Storing your Credentials article.

Examples

Get a list of all users

This script retrieves a list of all users from the Data Connector and stores it in a pandas dataframe.

from dcdcpy.dcdcpy import DataConnector

dc = DataConnector()
dataframe = dc.user_dim()
print(dataframe);

Get time spent on courses for a single user

This code will print a dataframe with all course activity for a single user, it lists the course, the amount of time spent (in seconds) and date for all their learning sessions.

from dcdcpy.dcdcpy import DataConnector

dc = DataConnector()

USER_EMAIL = 'john.doe@datacamp.com'

course_facts = dc.course_fact()
course_facts = course_facts \
    .merge(dc.course_dim(), left_on="course_id", right_on="course_id") \
    .merge(dc.user_dim(), left_on="user_id", right_on="user_id") \
    [['course_id', 'title', 'time_spent', 'date_id', 'email']]
    
print(course_facts[course_facts['email'] == USER_EMAIL])

More examples?

Reach out to your customer success manager and we are happy to help you get the data you need using our python library or SQL.

Last updated