New version
with open(f'output.csv', 'w') as f:
print(data, file=f)
Old version
with open(f'output.csv', 'w') as f:
f.write(data)
PySpark, BigData, SQL, Hive, AWS, Python, Unix/Linux, Shortcuts, Examples, Scripts, Perl
New version
with open(f'output.csv', 'w') as f:
print(data, file=f)
Old version
with open(f'output.csv', 'w') as f:
f.write(data)
vars = 'abc'
print(f 'Variable is : {vars}')
This is much better than 'Variable is : {}'.format(vars)
1. Stop mysql:
systemctl stop mysqld
2. Set the mySQL environment option
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
3. Start mysql usig the options you just set
systemctl start mysqld
4. Login as root
mysql -u root
5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
for 5.7.6 and later, you should use
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
mysql> quit
6. Stop mysql
systemctl stop mysqld
7. Unset the mySQL envitroment option so it starts normally next time
systemctl unset-environment MYSQLD_OPTS
8. Start mysql normally:
systemctl start mysqld
Try to login using your new password:
7. mysql -u root -p
Python Array Vs List
List | Array |
Heterigenous elements E.g, [1, 2, [3, 4], 5, 6] | Homogenous elements numbers = array.array('i', [1, 2, 3]) Explicitly define type of elements while defining (i - means integers |
Use lot more space | Use less spcace compared lists |
List contains pointers to different objects | Like C language arrays, with a pointer pointing to first element & rest are allocated in continuous memory |
More flexible keeping different structures of data | Less flexible |
Less efficient in storing & manipulating | More efficient in storing & manipulating |
Used when your collection grow & shrink in time efficient manner & manage lot of data types in a list | Used when you perform lot of computationally intensive math operations |
Numpy arrays are more suited for mathematical operations |