Package: babypandas
babypandasApandasdata-analysis library with a restricted APIThepandaslibrary  for tabular data analysis is powerful and popular, but perhaps not the easiest to learn: for nearly every
task, no matter how simple, there are multiple ways of approaching
it.babypandasis a simplified, introductorypandaslibrary that
allows for basic tabular data analysis with only a small subset of
methods and arguments. This restricted interface is designed to be easier to learn while still demonstrating fundamental principles and allowing for a smooth transition intopandasat a later time.The chosen methods are meant to align with the methods in Berkeley'sdatasciencemodule, developed for thedata8course. However, unlike thedatasciencemodule, all code written inbabypandasis also validpandascode.InstallTo installbabypandas, usepip:pip install babypandasDocumentationSee thedocumentationpage.FAQWho is this library for?This library is intended for those wanting an introduction to data
science in python, but want a focused, introduction much like what's
covered in Berkeley's data8 course. The pandas methods available in
this library encourage better Pandas usage through functional
programming  patterns and method chaining.Why not just use the datascience module?This library may be prefered overdatasciencewhen students
will be moving topandas. While this library serves as a restricted
introduction topandas, it doesn't shy away from somepandasusage patterns that may require care for new programmers:The frequent use of named function arguments,The use of boolean arrays (masks) to select rows,The use of table indices.How does this library compare to the datascience module?Berkeleydatasciencemodule equivalents withbabypandas:datasciencemethodbabypandasequivalent or closemethod descriptionTable()bpd.DataFrame()empty table formationTable().with_columns(*labels_and_values)bpd.DataFrame().assign(**kwargs)table from liststable.with_columns(*labels_and_values)df.assign(**kwargs)adding columnstable.with_rows(rows)df.append(other_df, ignore_index=True)Table.read_table(filepath)bpd.read_csv(filepath)read in datatable.num_columnsdf.shape[1]number of columnstable.num_rowsdf.shape[0]number of rowstable.labelsdf.columnslist of columnstable.relabeled(label, new_label)df.assign(new_label=df.get(label)).drop(columns=[label])rename columnstable.column(col)df.get(col)get a specific column (by name)table.column(col).item(0)df.get(col).iloc[0]get a specific value in the tabletable.select(col1, col2)df.get([col1, col2])get columns as a dftable.drop(col1, col2)df.drop(columns=[col1, col2])drop columnstable.sort(col)df.sort_values(by=col)sorts values in a dataframe by coltable.take(row_indices_or_slice)df.take(row_indices_or_slice)selects a single rowtable.where(col, are.above(num))df.loc[df.get(col) > num]selects rows based on conditiontable.scatter(xcol, ycol)df.plot(kind='scatter', x=xcol, y=ycol)plots a scatter plottable.plot(xcol, ycol)df.plot(x=xcol, y=ycol)plots a line plottable.barh(col)df.plot(kind='barh', x=col)plots a horizontal bar plottable.hist(col, bins)df.get(col).plot(kind='hist', bins=bins)plots a histogramtable.apply(fn, col)df.get(col).apply(fn)apply function to a columntable.group(col)df.groupby(col).count()give counts of values in a coltable.group(col, agg_fn)df.groupby(col).agg_fn.reset_index()groups by column, aggregates with fntable.group([col1, col2])df.groupby([col1, col2]).count().reset_index()groups by two cols, agg with countstable.group([col1, col2], sum)df.groupby[col1, col2]).sum().reset_index()groups by two cols, agg with sumtable.join(leftcol, df2, rightcol)df.merge(df2, left_on=leftcol, right_on=rightcol)merges two dataframes (diff col names)table.join(col, df2, col)df.merge(df2, on=col)merges two dataframes (same col names)table.sample(n)df.sample(n, replace=True)sample with replacementsample_proportions(size, distr)np.random.multinomial(size, distr) / sizegets sample proportions of a distributionDevelopmentPublishing to PyPI requires that a tagged commit exists on themasterbranch. The GitHub Actions workflow will trigger
package building and publishing to PyPI only when a commit onmasteris tagged. This can happen in one of two ways:Direct Tagged Commit to Master: Commit your changes directly tomasterand tag the commit before pushing to
GitHub.gitcommit-m"Your descriptive commit message"gittag<tag-name># convention has been to tag with package versiongitpushoriginmaster
gitpushorigin<tag-name>Merge Pull Request to Master and Post-Hoc Tag: Merge a pull request intomaster. After merging, tag the resulting
commit inmaster.gitcheckoutmaster
gitpulloriginmaster
gittag<tag-name>
gitpushorigin<tag-name>Either of these approaches will trigger testing, building, and publishing of the package to PyPI.