Claudio Cicali
Welcome to the official website of Claudio Cicali. This site serves as a central hub for information and updates.
Learn moreFollow along for the latest updates and announcements. Visit the homepage for more information.
Python or R for data wrangling: A practical choice
Data wrangling is where raw records become dependable evidence. A CSV from a government portal, a spreadsheet maintained by a regional office, or an export from a customer system can contain inconsistent dates, mixed types, duplicate rows and missing values. The language matters, but the quality of the checks matters more. Python and R can both turn unreliable inputs into analysable tables when they are used with deliberate rules.
The better choice depends on the team, the destination and the surrounding stack. Python is often strongest when transformation code must travel from a notebook into an application or cloud pipeline. R is often strongest for statistical exploration, domain-specific analysis and polished reporting. Australian conditions add practical considerations, from public-data formats to privacy duties, so the decision should be made against real work rather than popularity.
Start with the work, not the language
Begin by listing the actual tasks: parsing delimited files, reading Excel workbooks, querying PostgreSQL, reshaping tables, validating totals, geocoding addresses and publishing results. Include who will maintain the code and where outputs must run. A team that already deploys Python services has less friction extending that workflow, while a research group trained in R may produce faster, clearer transformations.
Assess data volume and latency as well. Tens of millions of rows within a laptop session may be comfortable in R with data.table or in Python with Polars, pandas or DuckDB, depending on operations and memory. Repeated database extraction changes the calculation: pushing filters and joins into the database often beats moving everything into either language.
Define what “done” means before selecting syntax. Required columns, row grain, accepted date formats, duplicate policy and reconciliation thresholds should be written down. Those rules expose whether a feature is essential. They also prevent a common mistake: choosing a tool because it reads the first sample, then discovering that incremental monthly extracts behave differently.
Python's path from raw rows to reliable tables
Python’s core advantage is interoperability. pandas provides the familiar DataFrame model, while pyarrow, Polars, DuckDB and database connectors support faster execution and larger data. The same objects can feed plotting, machine-learning, web and orchestration tools. For a scheduled process that begins with an API response and ends in a cloud warehouse, Python usually offers the shortest path through the wider engineering stack.
pandas remains a sensible default for moderate data because its concepts are well documented and widely taught. Explicit schemas, categorical data types and vectorised operations make common cleaning steps concise. Yet developers should treat automatic type inference cautiously. Australian postcodes should remain text, identifiers should not become floating-point values, and blank cells should not silently become zero.
Python also offers useful validation libraries and flexible command-line tooling. Teams can isolate pure transformation functions, test them against small fixtures and package the workflow with uv, Poetry, conda or containers. None of these tools guarantees correctness, but they make it easier to reject a malformed extract before it reaches a dashboard or downstream model.
R's strengths in expressive transformation
R combines a compact analytical grammar with an exceptionally strong ecosystem for statistics and graphics. Base R handles vectors and data frames directly, while readr, stringr, factor and lubridate cover routine ingestion and cleaning. For survey weights, experimental designs, survival analysis or biological domains, packages such as survey and Bioconductor can reduce custom code and keep methods defensible.
The tidyverse is often the clearest entry point for structured transformations. dplyr expresses filtering and joins clearly; tidyr pivots long and wide layouts; readr standardises import behaviour. These verbs create readable pipelines, and names such as select, mutate and summarise map closely to the steps described in a data dictionary. R is particularly effective when every table update must be understood by a non-programmer reviewer.
That does not make R a niche or slow choice. data.table performs substantial in-memory work, Arrow moves columnar data efficiently, and dbplyr can push work towards supported databases. The difference is usually one of defaults and institutional familiarity: R concentrates statistical intent in the language, whereas Python often relies on a broader collection of specialised libraries.
Files, databases and messy Australian inputs
Australian projects commonly draw on federal sources such as the Australian Bureau of Statistics and data.gov.au, then combine them with state, council or commercial records. Those files may arrive as CSV, JSON, XLSX, compressed archives or API responses. Before import, inspect headers and encodings rather than accepting every value as a string. Keep source names, retrieval dates and query parameters with the extract.
Local detail can be lost through careless assumptions. Daylight saving changes clock offsets in several states, while Perth uses Western Standard Time throughout the year. Dates spanning remote operations or national datasets should use ISO 8601 and explicit time zones. Everyday transport questions may combine weekday commuting patterns, public transport feeds, event calendars and rainfall observations across Sydney, Melbourne, Brisbane and Perth; stable geographic identifiers are more reliable than copied suburb labels.
Some inputs contain media rather than tidy rows. A virtual exhibition may combine object records, coordinates, captions and panoramic images. This 360-degree museum tours illustrates how cultural and city collections can be presented spatially, but the underlying transformation still needs consistent asset IDs, rights fields and image metadata. The same discipline applies whether the source is a survey, a warehouse inventory or a museum catalogue.
Reproducibility, validation and collaboration
Reproducibility turns a successful script into a maintainable asset. Pin package versions with renv in R or a locked Python environment, record random seeds where relevant, and store a small sample of sensitive source data for testing. Automated checks should confirm schemas, row counts, uniqueness and control totals. A clean run on one laptop is not enough if the next analyst receives different dependencies.
Notebooks suit investigation because they combine narrative, code, tables and charts. For recurring production work, move reusable transformations into ordinary source files and keep the notebook focused on interpretation. Quarto can support both Python and R, allowing shared reports to call language-specific cleaning steps. This arrangement reduces hidden state and gives reviewers a clear place to inspect logic.
Version control completes the handoff. Commit code, configuration and documentation together, but exclude credentials and personal records. Record where data came from and how consent, permitted purpose and retention were assessed. These habits matter even when all processing occurs locally, because scripts can outlive the project brief and the person who first approved the data.
A decision path for Australian teams
Local cloud availability is another practical factor. Australia has hosted regions operated by major platform providers, and procurement teams often compare latency, support, security controls and managed services before choosing one. A Python workflow may align naturally with cloud notebooks, APIs and data warehouses; R may fit an existing research platform. The deciding factor is operational fit, not a generic claim about speed.
Legal and governance checks belong in the design, not at the end. Under the Privacy Act 1988, personal information must be handled for an authorised purpose and protected according to the Australian Privacy Principles when the Act applies. Public data can still contain identifiers or commercial confidences. If transformed outputs support consumer pricing or claims, the Australian Consumer Law may also affect how those figures are represented.
For a new team with mixed skills, run one representative extract in both ecosystems. Score schema handling, join complexity, runtime, testability and the ease of explaining results to domain staff. Then estimate the ongoing cost: training, integration, deployment and maintenance usually outweigh modest gains from a small benchmark. If the scores are close, follow the stack already supported by the organisation.
The durable distinction is not that Python or R is universally superior. Python is usually the stronger connective tissue for applications, automation and mixed software systems; R is usually the more direct environment for statistical analysis and coherent data transformation. Both can produce careful work when schemas, assumptions and checks are explicit.
The strongest toolchain is the one that matches the data, the people who must maintain it and the system consuming its outputs, while satisfying Australian legal, operational and data-quality realities.