Skip to content

Instantly share code, notes, and snippets.

@jpigla
Last active June 27, 2019 08:52
Show Gist options
  • Save jpigla/709abb6a4d66c0d9623d31b430d91a9d to your computer and use it in GitHub Desktop.
Save jpigla/709abb6a4d66c0d9623d31b430d91a9d to your computer and use it in GitHub Desktop.

Python

Panda

Number of List items displayed

pd.options.display.max_rows = 4000

Number of characters displayed in cell

pd.set_option('max_colwidth', 0) (0 = 'kein Limit')

Save to CSV output

df.to_csv('filename.csv')

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html

Bookmarks

Use-Cases

import pandas as pd
df = pd.read_csv("all_outlinks.csv")

dfx = df.loc[df['Type'].str.match('AHREF')]
dfx = dfx.loc[dfx['Destination'].str.contains('firefox',regex=False)]
dfx = dfx.loc[:,['Type','Source','Destination','Status Code']]

print (dfx)
  • Import CSV
  • Select only rows where value in column "Type" matches "AHREF"
  • Select only rows where value in column "Destination" contains "firefox" (default=regex)
  • Return all rows (":") with selected columns ['Type','Source','Destination','Status Code']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment