- import pandas as pd
- #import random and use it as random.sample
- from random import sample
- #Let us create some data using sample from random module
- #Create two lists
- country_list = ["USA", "Russia","China","India"]
- #Using the name list, let us create three variables using sample() function
- top1 = sample(country_list,4)
- top2 = sample(country_list,4)
- top3 = sample(country_list,4)
- #Now, we can use these lists to create a dataframe with 3 columns
- df = pd.DataFrame({"Top1":top1,
- "Top2":top2,
- "Top3":top3,
- })
- print(df)
-
- Active Topics
-
-
- by Eli 18 hours ago Re: What is in Your Mind? View the latest post Replies 703 Views 299815
- by Eli 18 hours ago Russia Invades Ukraine View the latest post Replies 663 Views 234964
- by Eli 2 days ago All in One: YouTube, TED, X, Facebook and Instagram Reels, Videos, Images and Text Posts View the latest post Replies 326 Views 34007
- by Eli 3 days ago PySpark for Large Data Processing View the latest post Replies 1 Views 6775
- by Eli 1 week ago President Museveni's Speech During International Development Association (IDA) Summit View the latest post Replies 1 Views 280
- by Eli 1 week ago From Simple Linear Regression Analysis to Covariance & Correlation to Independent Determinant, and R-Squared View the latest post Replies 11 Views 24833
- by Eli 1 week ago Collection of Greatest Christian Hymns of all Times View the latest post Replies 34 Views 67173
- by Eli 1 week ago Pondering Big Cosmology Questions Through Lectures and Dialogues View the latest post Replies 34 Views 58068
- by Eli 1 week ago Programmatically Manipulate Files: Renaming, Reading, Writing, Deleting, and Moving Files Between Folders View the latest post Replies 7 Views 15594
- by Eli 2 weeks ago Iran Launches Retaliatory Attack Against Israel, and Israel Retaliates by Attacking Iranian Isfahan Millitary Base View the latest post Replies 28 Views 17592
-
Live Programming and Computing with Python, R, Sage, Octave, Maxima, Singular, Gap, GP, HTML & Macaulay2
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5382
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
Testing Sample Module
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5382
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
Here is a SnapPy, what is it ?
SnapPy is a program for studying the topology and geometry of 3-manifolds, with a focus on hyperbolic structures. It runs on Mac OS X, Linux, and Windows, and combines a link editor and 3D-graphics for Dirichlet domains and cusp neighborhoods with a powerful command-line interface based on the Python programming language.
SnapPy can be installed on Linux as follows:
Ubuntu/Debian/Mint: Tested on Ubuntu 20.04:
Users of Ubuntu 18.04 or older should do:
On TSSFL Stack, SnapPy is installed and can be used via SageMath. We can at once import the whole Stack of SnapPy modules and start testing it immediatelly:
To explore SnapPy Manifold class for example (unfortunately tinker is not installed on SageMath), open Ubuntu LInux Terminal and evoke Python/Ipython interpreter, import Manifold and execute the below simple code:
SnapPy is a program for studying the topology and geometry of 3-manifolds, with a focus on hyperbolic structures. It runs on Mac OS X, Linux, and Windows, and combines a link editor and 3D-graphics for Dirichlet domains and cusp neighborhoods with a powerful command-line interface based on the Python programming language.
SnapPy can be installed on Linux as follows:
Ubuntu/Debian/Mint: Tested on Ubuntu 20.04:
- sudo apt-get install python3-tk python3-pip
- # Note no "sudo" on the next one!
- python3 -m pip install --upgrade --user snappy
- sudo apt-get install python3-tk python3-pip
- # Note no "sudo" on the next two
- python3 -m pip install --upgrade --user pip wheel
- python3 -m pip install --upgrade --user snappy
On TSSFL Stack, SnapPy is installed and can be used via SageMath. We can at once import the whole Stack of SnapPy modules and start testing it immediatelly:
- from snappy import Manifold, Triangulation, Manifold, ManifoldHP, AbelianGroup, FundamentalGroup, HolonomyGroup, HolonomyGroupHP, DirichletDomain, DirichletDomainHP, CuspNeighborhood, CuspNeighborhoodHP, SymmetryGroup, AlternatingKnotExteriors, NonalternatingKnotExteriors, SnapPeaFatalError, InsufficientPrecisionError, pari, twister, OrientableCuspedCensus, NonorientableCuspedCensus, OrientableClosedCensus, NonorientableClosedCensus, LinkExteriors, CensusKnots, HTLinkExteriors, TetrahedralOrientableCuspedCensus, TetrahedralNonorientableCuspedCensus, OctahedralOrientableCuspedCensus, OctahedralNonorientableCuspedCensus, CubicalOrientableCuspedCensus, CubicalNonorientableCuspedCensus, DodecahedralOrientableCuspedCensus, DodecahedralNonorientableCuspedCensus, IcosahedralNonorientableClosedCensus, IcosahedralOrientableClosedCensus, CubicalNonorientableClosedCensus, CubicalOrientableClosedCensus, DodecahedralNonorientableClosedCensus, DodecahedralOrientableClosedCensus, Crossing, Strand, Link, Tangle, RationalTangle, ZeroTangle, InfinityTangle, IdentityBraid, random_link, DTcodec
- A = AbelianGroup(elementary_divisors=[5,15,0,0])
- print(A)
- print(A[0])
- M = Manifold('m004')
- print(M.symmetry_group())
- M = Manifold('K7_1')
- G = M.fundamental_group()
- g = G.generators_in_originals()
- print(g)
- #M.inside_view()
- from snappy import Manifold
- M = Manifold('m004')
- M.inside_view()
- %gui tk
- #Code 2
- from snappy import ManifoldHP
- M = ManifoldHP('14n12345') #Try M = ManifoldHP('15n4321')
- M.volume()
- M.plink()
- M.browse()
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5382
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
- import pandas as pd
- import re
- # Sample data
- data = {'date_time': ['Random text 2023-09-03 00:20:00 more text', 'Some other text', '2023-09-03 00:20:00 additional text']}
- df = pd.DataFrame(data)
- # Extract the first datetime occurrence with the desired format
- pattern = r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
- first_datetime = re.search(pattern, ' '.join(df['date_time']))
- if first_datetime:
- # Extract the time from the first datetime occurrence
- first_time = first_datetime.group().split()[1]
- print(first_time)
- else:
- print("Datetime not found in DataFrame.")
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5382
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
Python Polars is an alternative to Pandas, written with performance in mind. Test it:
- import polars as pl
- from datetime import datetime
- df = pl.DataFrame(
- {
- "integer": [1, 2, 3, 4, 5],
- "date": [
- datetime(2023, 1, 1),
- datetime(2023, 1, 2),
- datetime(2023, 1, 3),
- datetime(2023, 1, 4),
- datetime(2023, 1, 5),
- ],
- "float": [4.0, 5.0, 6.0, 7.0, 8.0],
- }
- )
- print(df)
- print(df.sample(2))
- print(df.describe())
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5382
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
Test Vega Altair
- # import altair with an abbreviated alias
- import altair as alt
- # load a sample dataset as a pandas DataFrame
- from vega_datasets import data
- cars = data.cars()
- # make the chart
- chart = alt.Chart(cars).mark_point().encode(
- x='Horsepower',
- y='Miles_per_Gallon',
- color='Origin',
- ).interactive()
- chart.save('chart.html') # Save to file
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
-
- Similar Topics
- Replies
- Views
- Last post
-
- Information
-
Who is online
Users browsing this forum: No registered users and 1 guest