Have two columns in Markdown

While this doesn’t work for all dialects of Markdown, I got this to work with GitLab, GitHub, and mdBook. Basically, you create the table via HTML. Markdown and HTML don’t mix well, but if you surround the Markdown with whitespace, sometimes the Markdown can be recognized. https://docs.gitlab.com/ee/user/markdown.html#inline-html <table> <tr> <th> Good </th> <th> Bad </th> … Read more

How to constuct a column of data frame recursively with pandas-python?

You can use: df.loc[0, ‘diff’] = df.loc[0, ‘val’] * 0.4 for i in range(1, len(df)): df.loc[i, ‘diff’] = (df.loc[i, ‘val’] – df.loc[i-1, ‘diff’]) * 0.4 + df.loc[i-1, ‘diff’] print (df) id_ val diff 0 11111 12 4.8000 1 12003 22 11.6800 2 88763 19 14.6080 3 43721 77 39.5648 The iterative nature of the calculation … Read more

How to paste columns from separate files using bash?

You were on track with paste(1): $ paste -d , date1.csv date2.csv Bob,2013-06-03T17:18:07,2012-12-02T18:30:31 James,2013-06-03T17:18:07,2012-12-02T18:28:37 Kevin,2013-06-03T17:18:07,2013-06-01T12:16:05 It’s a bit unclear from your question if there are leading spaces on those lines. If you want to get rid of that in the final output, you can use cut(1) to snip it off before pasting: $ cut -c … Read more

Splitting multiple columns into rows in pandas dataframe

You can first split columns, create Series by stack and remove whitespaces by strip: s1 = df.value.str.split(‘,’, expand=True).stack().str.strip().reset_index(level=1, drop=True) s2 = df.date.str.split(‘,’, expand=True).stack().str.strip().reset_index(level=1, drop=True) Then concat both Series to df1: df1 = pd.concat([s1,s2], axis=1, keys=[‘value’,’date’]) Remove old columns value and date and join: print (df.drop([‘value’,’date’], axis=1).join(df1).reset_index(drop=True)) ticker account value date 0 aa assets 100 20121231 … Read more