Category Archives: Julia

Julia: Data Wrangling using JuliaDB.jl and JuliaDBMeta.jl

By: Estadistika -- Julia

Re-posted from: https://estadistika.github.io//data/analyses/wrangling/julia/programming/packages/2018/06/08/Julia-Introduction-to-Data-Wrangling.html

I’m a heavy user of Python’s pandas and R’s dplyr both at work and when I was taking my master’s degree. Hands down, both of these tools are very good at handling the data. So what about Julia? It’s a fairly new programming language that’s been around for almost 6 years already with a very active community. If you have no idea, I encourage you to visit Julialang.org. In summary, it’s a programming language that walks like a Python, but runs like a C.

For data wrangling, there are two packages that we can use, and these are DataFrames.jl and JuliaDB.jl. Let me reserve a separate post for DataFrames.jl, and instead focus on JuliaDB.jl and JuliaDBMeta.jl (an alternative for querying the data, like that of R’s dplyr) packages.

Package Installation

By default, the libraries I mentioned above are not built-in in Julia, and hence we need to install it:

Data: nycflights13

In order to compare Julia’s capability on data wrangling with that of R’s dplyr, we’ll reproduce the example in this site. It uses all 336,776 flights that departed from New York City in 2013. I have a copy of it on github, and the following will download and load the data:

The rows of the data are not displayed as we execute nycflights in line 7, that’s because we have a lot of columns, and by default JuliaDB.jl will not print all these unless you have a big display (unfortunately, I’m using my 13 inch laptop screen, and that’s why). Hence, for the rest of the article, we’ll be using selected columns only:

Filter Rows

Filtering is a row-wise operation and is done using the Base.filter function with extended method for JuliaDB.IndexedTables.
Therefore, to filter the data for month equal to 1 (January) and day equal to 1 (first day of the month), is done as follows:

To see the output for line 2 using Base.filter, simply remove the semicolon and you’ll have the same output as that of line 5 (using JuliaDBMeta.@filter).

Arrange Rows

To arrange the rows of the columns, use Base.sort function:

Select Columns

We’ve seen above how to select the columns, but we can also use ranges of columns for selection.

Rename Column

To rename the column, use JuliaDB.renamecol function:

Add New Column

To add a new column, use insertcol, insertcolafter and insertcolbefore of the JuliaDB.jl.

or use the @transform macro of the JuliaDBMeta.jl:

Summarize Data

The data can be summarized using the JuliaDB.summarize function

@with macro is an alternative from JuliaDBMeta.jl.

Grouped Operations

For grouped operations, we can use the JuliaDB.groupby function or the JuliaDBMeta.@groupby:

We’ll use the summarized data above and plot the flight delay in relation to the distance travelled. We’ll use the Gadfly.jl package for plotting and DataFrames.jl for converting JuliaDB.jl’s IndexedTable objects to DataFrames.DataFrame object, that’s because Gadfly.plot has no direct method for JuliaDB.IndexedTables.

To plot, run the following:


To find the number of planes and the number of flights that go to each possible destination, run:

Piping Multiple Operations

For multiple operations, it is convenient to use piping and that is the reason why we have tools like JuliaDBMeta.jl. The following example using R’s dplyr:

is equivalent to the following Julia code using JuliaDBMeta.jl:

Conclusion

I’ve demonstrated how easy it is to use Julia for doing data wrangling, and I love it. In fact, there is a library that can query any table-like data structure in Julia, and is called Query.jl (will definitely write a separate article for this in the future).

For more on JuliaDB.jl, watch the Youtube tutorial.

Newsletter – June 2018

Julia Highlights for June 2018

  1. JuliaCon 2018: Early Bird Pricing Ends June 15
  2. Online Instructor-Led Training in Artificial Intelligence and Machine Learning
  3. JuliaBox Supports Parallel and Distributed Computing
  4. Julia and Julia Computing in the Media
  5. Recent Julia Videos
  6. Recent Julia Blog Posts
  7. Upcoming and Recent Julia Events and Meetup Groups
  8. Julia Jobs, Fellowships and Internships
  9. Contact Us, About Julia and Julia Computing


1. JuliaCon 2018: Early Bird Pricing Ends June 15:

Click here to purchase your JuliaCon tickets by June 15, before prices increase. JuliaCon 2018 takes place Aug 7-11 at UCL in London, United Kingdom. You are encouraged to book your travel and lodging as soon as possible to take advantage of the best prices and availability. Corporate sponsorship opportunities are available.

2. Online Instructor-Led Training in Artificial Intelligence and Machine Learning:

Julia Computing provides online instructor-led training in artificial intelligence and machine learning. This month, the course is  being taught by Alan Edelman, Professor of Applied Mathematics at MIT and Chief Scientist at Julia Computing.
Each class is 8 hours of instruction: four hours per day for two consecutive days.
Introduction to Machine Learning and Artificial Intelligence
Part 1: Thursday June 28, 8 am – 12 noon US Eastern Time
Part 2: Friday June 29, 8 am – 12 noon US Eastern Time
Cost: US$300.00
Please click here to register.
If you would like to schedule in person or online training for your organization, please contact us at [email protected]. You can learn more about our training programs here.

3. JuliaBox Supports Parallel and Distributed Computing:

JuliaBox is available at scale with parallel and distributed computing capabilities. JuliaBox runs in the cloud on dozens, hundreds or thousands of nodes, depending on your requirements. As always, there is no download required with JuliaBox – you can run a Jupyter notebook straight from your browser. Full JuliaBox documentation including examples and reference information for parallel and distributed functionality is available here. For pricing and sign up, click here. The free version of JuliaBox continues to be fully supported and available for all current and new users with the latest version of Julia, package updates, new features and improved memory, flexibility and reliability.

4. Julia and Julia Computing in the Media

a. Julia Computing on DM Radio:
Julia Computing CEO Viral Shah and Chief Scientist Alan Edelman joined DM Radio host Eric Kavanagh, Jupyter Conference Program Co-Chair Paco Nathan and NexJ Senior Director of Analytics and Data Science Martin Sykora to discuss “Julia, Python and R: The Rise of Jupyter Notebooks.” Click here to listen.

b. Julia on TV’s Hit Show ‘Billions’:Julia’s television career continues to flourish. This year, Julia appeared on the hit television show Billions. This follows Julia appearances on other television programs such as The 100 and Casual.

c. Julia Computing Week at Universidad Panamericana (En Español):Julia Computing’s Jane Herriman of Caltech and Lawrence Livermore National Laboratory led a week of data science and machine learning training in Julia for 60 students at Universidad Panamericana in Mexico City.

d. Jupyter Wins Software System Award:Jupyter, which is named for Julia, Python and R, has won the Association for Computing Machinery Software System Award. “Jupyter’s developers … collaborated … to be able to run Julia”.

5. Recent Julia Videos

6. Recent Julia Blog Posts

7. Upcoming and Recent Julia Events and Meetup Groups

a. Upcoming Julia Events:

b. Recent Julia Events

c. Julia Meetup Groups:

There are 34 Julia Meetup groups worldwide with more than 6.8 thousand members. If there’s a Julia Meetup group in your area, we hope you will consider joining, participating and helping to organize events. If there isn’t, we hope you will consider starting one.

8. Julia Jobs and Internships

Do you work at or know of an institution looking to hire Julia programmers as staff, research fellows or interns? Would your employer be interested in hiring interns to work on open source packages that are useful to their business? Help us connect members of our community to great opportunities by sending us an email, and we’ll get the word out!

There are more than 200 Julia jobs currently listed on Indeed.com, including jobs at Google, Facebook, IBM, KPMG, Ernst & Young, Booz Allen Hamilton, Comcast, Zulily, National Renewable Energy Research Laboratory, Los Alamos National Laboratory, Brown, Princeton, Columbia, Notre Dame, MIT, University of Chicago and many more.

9. Contact Us

Please contact us if you wish to:

  • Purchase or obtain license information for Julia products such as JuliaPro, JuliaPro Enterprise, JuliaRun, JuliaDB, JuliaFin or JuliaBox
  • Obtain pricing for Julia consulting projects for your organization
  • Schedule Julia training for your organization
  • Share information about exciting new Julia case studies or use cases
  • Spread the word about an upcoming conference, workshop, training, hackathon, meetup, talk or presentation involving Julia
  • Partner with Julia Computing to organize a Julia meetup, conference, workshop, training, hackathon, talk or presentation involving Julia
  • Submit a Julia internship or job posting

About Julia and Julia Computing

Julia is the fastest high performance open source computing language for data, analytics, algorithmic trading, machine learning, artificial intelligence, and many other domains. Julia solves the two language problem by combining the ease of use of Python and R with the speed of C++. Julia provides parallel computing capabilities out of the box and unlimited scalability with minimal effort. For example, Julia has run at petascale on 650,000 cores with 1.3 million threads to analyze over 56 terabytes of data using Cori, the world’s sixth-largest supercomputer. With more than 1.8 million downloads and +101% annual growth, Julia is one of the top programming languages developed on GitHub. Julia adoption is growing rapidly in finance, insurance, machine learning, energy, robotics, genomics, aerospace, medicine and many other fields.

Julia Computing was founded in 2015 by all the creators of Julia to develop products and provide professional services to businesses and researchers using Julia. Julia Computing offers the following products:

  • JuliaPro for data science professionals and researchers to install and run Julia with more than one hundred carefully curated popular Julia packages on a laptop or desktop computer.
  • JuliaRun for deploying Julia at scale on dozens, hundreds or thousands of nodes in the public or private cloud, including AWS and Microsoft Azure.
  • JuliaFin for financial modeling, algorithmic trading and risk analysis including Bloomberg and Excel integration, Miletus for designing and executing trading strategies and advanced time-series analytics.
  • JuliaDB for in-database in-memory analytics and advanced time-series analysis.
  • JuliaBox for students or new Julia users to experience Julia in a Jupyter notebook right from a Web browser with no download or installation required.

To learn more about how Julia users deploy these products to solve problems using Julia, please visit the Case Studies section on the Julia Computing Website.

Julia users, partners and employers hiring Julia programmers in 2018 include Amazon, Apple, BlackRock, Booz Allen Hamilton, Capital One, Comcast, Disney, Ernst & Young, Facebook, Ford, Google, IBM, Intel, KPMG, Microsoft, NASA, Oracle, PwC, Uber, and many more.