A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| <?php | |
| function array_keys_multi(array $array) | |
| { | |
| $keys = array(); | |
| foreach ($array as $key => $value) { | |
| $keys[] = $key; | |
| if (is_array($array[$key])) { | |
| $keys = array_merge($keys, array_keys_multi($array[$key])); |
| # Redis Cheatsheet | |
| # All the commands you need to know | |
| redis-server /path/redis.conf # start redis with the related configuration file | |
| redis-cli # opens a redis prompt | |
| # Strings. |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| import pandas as pd | |
| # Read file | |
| results = pd.read_csv("/tmp/data.csv", encoding='utf-8',sep=',', quoting=csv.QUOTE_ALL) | |
| # Print rows | |
| for row in results: | |
| print(row) | |
| # Iterate over rows |
| # -*- coding: utf-8 -*- | |
| # import pandas and numpy package | |
| import numpy as np | |
| import pandas as pd | |
| # List unique values in a DataFrame column | |
| df['Column Name'].unique() | |
| # To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation. |
| # coding: utf8 | |
| """ | |
| Goal: import csv to database. | |
| pip install pandas, numpy | |
| """ | |
| import pandas | |
| import numpy as np |
| from pyelasticsearch import ElasticSearch | |
| import pandas as pd | |
| from time import time | |
| root_path="/home/clemsos/Dev/mitras/" | |
| raw_data_path=root_path+"data/" | |
| csv_filename="week10.csv" | |
| t0=time() |
| # Initialize the scroll | |
| page = es.search( | |
| index = 'yourIndex', | |
| doc_type = 'yourType', | |
| scroll = '2m', | |
| search_type = 'scan', | |
| size = 1000, | |
| body = { | |
| # Your query's body | |
| }) |
You have to do 2 things in order to allow your container to access your host's postgresql database
Obs: By "Host" here I mean "the server where docker is running on".
Find your postgresql.conf (in case you don't know where it is)
$ sudo find / -type f -name postgresql.conf
| <?php | |
| require_once("PHPExcel/PHPExcel.php"); | |
| $phpExcel = new PHPExcel(); | |
| $styleArray = array( | |
| 'font' => array( | |
| 'bold' => true, | |
| ) | |
| ); |