Skip to content

Instantly share code, notes, and snippets.

@katronai
katronai / strings.py
Last active March 3, 2020 21:17
String formatting and operations in Python 3.
# Print without line break
print('*', end='')
# Print without spaces between arguments
print('a', 'b', 'c', sep='')
# Flush the output in case of buffering problems
print('*', end='', flush=True)
# String formatting: https://docs.python.org/3/library/string.html#formatstrings
@katronai
katronai / pandas.md
Last active March 12, 2020 20:38
Pandas operations

Importing Data

  • Dictionary to DataFrame
df = pd.Dataframe(my_dict)
  • Dictionary to DataFrame with row labels
@katronai
katronai / looping.py
Created March 3, 2020 22:44
Looping in Python 3.
# Loop through list
for item in list:
print(item)
# Loop through list with index
for index, item in enumerate(list):
print(index, item)
# Loop through dictinary:
for key, value in dict.items():